Constructing a MailMessage object exposes further options, including the ability to add attachments:
using System;
using System.Net;
using System.Net.Mail;
using System.Threading;
using System.IO;
using System.Text;
class ThreadTest
{
static void Main()
{
SmtpClient client = new SmtpClient();
client.Host = "mail.myisp.net";
MailMessage mm = new MailMessage();
mm.Sender = new MailAddress("[email protected]", "J");
mm.From = new MailAddress("[email protected]", "k");
mm.To.Add(new MailAddress("[email protected]", "b"));
mm.CC.Add(new MailAddress("[email protected]", "d"));
mm.Subject = "Hello!";
mm.Body = "Hi there. ";
mm.IsBodyHtml = false;
mm.Priority = MailPriority.High;
Attachment a = new Attachment("photo.jpg", System.Net.Mime.MediaTypeNames.Image.Jpeg);
mm.Attachments.Add(a);
client.Send(mm);
}
}
| w___w___w_.___j__a_va__2__s__.__c_om__ | Contact Us |
| Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
| All other trademarks are property of their respective owners. |