Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I need a C# code to send, receive and validate email to put on website, any helpers?
Posted
Updated 6-May-14 9:54am
v2
Comments
Sergey Alexandrovich Kryukov 6-May-14 15:54pm    
What's wrong with just reading standard MSDN documentation?
—SA

For this purpose, the class System.Net.Mail.MailMessage has the property Attachments:
http://msdn.microsoft.com/en-us/library/System.Net.Mail.MailMessage%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.attachments%28v=vs.110%29.aspx[^].

The second link shows some code sample of adding an attachment.

Good luck.
—SA
 
Share this answer
 
Try this...

MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(emailAddress);
// Recipient e-mail address.
Msg.To.Add("TO ADDRESS");
Msg.Subject = "ADD SUBJECT";
Msg.Body = "MSG BODY";
Msg.IsBodyHtml = true;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("FROM ADDRESS (Mail Id)", "PASSWORD");
smtp.EnableSsl = true;
smtp.Send(Msg);
 
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