Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new for sending email. I have tried many tutorial Lessons, but i did not work. I think it may cause of my IIS service. There is no Virtual Directory in SMTP E-Mail but i have installed IIS already. When I wrote code for sending Email it had some error and warning

C#
// NameSpace
using System.Web.Mail;


            MailMessage mymail = new MailMessage();
            mymail.To = txtTo.Text.ToString();
            mymail.From = "[DELETED]@hotmail.com";
            mymail.Subject = txtSubject.Text.ToString();
            mymail.Body = txtMessage.Text.ToString();

            SmtpMail.SmtpServer = "localhost";
         
            SmtpMail.Send(mymail);


there SmtpMail was highlighted as warning and the warning show "System.Web.Mail.SmtpMail is obsolete. The recommended alternative is system.Net.Mail.SmtpClient http://go.microsoft.com/fwlink/?linkid = 14202"

I still test my project at my laptop,havent registered for domain name yet. I just want to test my project on my computer (Is it possible not to apply for the domain name?) Pleaseeeee help me ....... Thanks so much



I really need your help,


[edit]Email removed - OriginalGriff[/edit]
Posted
Updated 8-Sep-12 23:40pm
v2
Comments
OriginalGriff 9-Sep-12 5:40am    
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know
Abigaill 9-Mar-17 9:21am    
I've used the code from this article: Send Email in C#, VB.NET and ASP.NET[^].

Have a look here: Sending an Email in C# with or without attachments: generic routine.[^] - it's a generic routine that works fine for me!
 
Share this answer
 
 
Share this answer
 
Comments
Cmajorros 9-Sep-12 10:46am    
I have tried ,but there was an error about "smtp.Credentials = new NetworkCredential(fromAddress, fromPassword);" It show an error at NetworkCredential. Do I have to declare any namespaces? and how can i know what is my fromAddress and fromPassword. How can I get them ?
[no name] 10-Sep-12 4:23am    
yes, you should have to add namespace "using System.Net;"
Hi,
Check this
sending emails in asp.net[^]
Best Regards
M.Mitwalli
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900