ASP.NET - mail not send - Asked By msakt on 28-Jun-12 04:26 AM

i have smtp host and port no which smtp s mail send from local application...

but is not working in error occure....
but mail send message is display

Jitendra Faye replied to msakt on 28-Jun-12 04:31 AM
Use this code and let me know

protected void yourButton_Click(object sender, EventArgs e)
    string strMailContent = "Welcome new user";
    string fromAddress = "";
    string toAddress = "";
    string contentId  = "image1";
    string path = Server.MapPath(@"images/Logo.jpg"); // my logo is placed in images folder
    MailMessage mailMessage = new MailMessage( fromAddress, toAddress );
    mailMessage.Bcc.Add(""); // put your id here
    mailMessage.Subject = "Welcome new User";
    LinkedResource logo = new LinkedResource(path);
    logo.ContentId = "companylogo";
   // done HTML formatting in the next line to display my logo
    AlternateView av1 = AlternateView.CreateAlternateViewFromString("<html><body><img src=cid:companylogo/><br></body></html>" + strMailContent, null, MediaTypeNames.Text.Html);
    mailMessage.IsBodyHtml = true;
    SmtpClient mailSender = new SmtpClient("localhost"); //use this if you are in the development server