Using System.Web.Mail;
MailMessage Mail = new MailMessage();
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate","1");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "vijayfreak@gmail.com");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "Type ur passwor here");
Mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
try
{
Mail.To = "vijayfreak@yahoo.co.in";
Mail.From = "vijay@test.com";
Mail.Subject = "Test message";
Mail.Body = "Test message";
Mail.Cc = "vijayfreak@gmail.com,vijay_mckvm@yahoo.co.in";
MailAttachment m = new MailAttachment("C:\\Documents and Settings\\A\\Desktop\\images.jpg");
Mail.Attachments.Add(m);
SmtpMail.SmtpServer = "smtp.gmail.com:456";
SmtpMail.Send(Mail);
}
catch (Exception ex)
{
Response.Write(ex.ToString() );
}
No comments:
Post a Comment