Sending multiple emails with attachments via via gmail

MailMessage cv_emailer = new MailMessage();

cv_emailer.From = new MailAddress(“….@……com”, “Vivek Mehta”);
cv_emailer.Subject = “Report from Vivek Mehta”;
cv_emailer.IsBodyHtml = false;
cv_emailer.Priority = MailPriority.High;

if (FileUpload1.HasFile) cv_emailer.Attachments.Add(new Attachment(FileUpload1.PostedFile.InputStream, “Vivek Mehta Report.doc”));

SmtpClient smtp = new SmtpClient();
System.Net.NetworkCredential authInfo = new System.Net.NetworkCredential(“[username]“, “[password]”);
smtp.Host =  “”;
smtp.UseDefaultCredentials = false;
smtp.Credentials = authInfo;
smtp.EnableSsl = true;

while (dr.Read())
cv_emailer.Body = “Dear ” + dr[“Name”].ToString() + “n” + EmailContent;
catch (Exception ex)
//Exception code

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s