Tuesday, 29 April 2014

Send Mail with Attachment in asp.net

 MailAddress SendFrom = new MailAddress("brijesh.singh879@gmail.com", "Brijesh");
        MailAddress SendTo = new MailAddress("brijesh.singh879@gmail.com");
        System.Net.Mail.MailMessage MyMessage = new System.Net.Mail.MailMessage(SendFrom, SendTo);
        MyMessage.IsBodyHtml = true;
        MyMessage.Subject = "Send Mail with attachment ";
        MyMessage.Body = "Body";
        if (fupResume.HasFile)
        {
            string FileName = Path.GetFileName(fupResume.PostedFile.FileName);
            MyMessage.Attachments.Add(new Attachment(fupResume.PostedFile.InputStream, FileName));
        }
        System.Net.NetworkCredential authentication = new System.Net.NetworkCredential("brijesh.singh879@gmail.com", "password");
        SmtpClient client = new SmtpClient("smtp.gmail.com", 25);//587
        client.EnableSsl = true;
        client.UseDefaultCredentials = true;
        client.Credentials = authentication;
        client.Send(MyMessage);

1 comment:

  1. yu merit casino - xn--o80b910a26eepc81il5g.online
    yu merit 메리트카지노총판 casino. kadangpintar · · · · · ·. ·. 1xbet ·. ·.. ·. ·... ·. yu 【z】⚡【fors】➤ yu 【n】pokergabet casino【n】casino sign up bonus.

    ReplyDelete