Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
send a mail with attachemt source code in asp.net
Posted 14-Feb-13 1:11am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Quote:
Hi..
 
MailMessage message = new MailMessage();
message.From = new MailAddress("xyz@gmail.com");
message.To.Add(anothermail);
message.Subject = "your subject";
message.Body = "your message body";
message.IsBodyHtml = true;
if (IsAttachmentValid(FileUploadAttachment))
{
message.Attachments.Add(new Attachment(FileUploadAttachment.PostedFile.InputStream, FileUploadAttachment.FileName));
}

SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 25);
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("xyz@gmail.com", "");
smtpClient.EnableSsl = true;
smtpClient.Send(message);
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 448
1 Sergey Alexandrovich Kryukov 425
2 Abhinav S 408
3 sanket saxena 285
4 Tadit Dash 160
0 Sergey Alexandrovich Kryukov 8,482
1 OriginalGriff 4,830
2 Peter Leow 3,794
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 14 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid