Click here to Skip to main content
Sign Up to vote bad
good
See more: ASP.NET
public void SendHTMLMail()
    {
        MailMessage Msg = new MailMessage();
        MailAddress fromMail = new MailAddress("xxxxx@gmail.com");
        // Sender e-mail address.
        Msg.From = fromMail;
        // Recipient e-mail address.
        Msg.To.Add(new MailAddress("xxxxxxxx@gmail.com"));
        // Subject of e-mail
        Msg.Subject = "Send Gridivew in EMail";
        Msg.Body += "Please check below data <br /><br />";
        Msg.Body += GetGridviewData(gvUserInfo);
        Msg.IsBodyHtml = true;
        string sSmtpServer = "";
        sSmtpServer = "587";
        SmtpClient a = new SmtpClient();
        a.Host = sSmtpServer;
        a.EnableSsl = true;
        a.Send(Msg);
    }
if i execute it show error....
Posted 2 Oct '12 - 19:00
Edited 2 Oct '12 - 19:12

Comments
Abhijit Parab - 3 Oct '12 - 1:04
what error it shows?

2 solutions

Quote:
System.Net.Mail;
using System.Net;
 
var fromAddress = new MailAddress("from@gmail.com", "From Name");
var toAddress = new MailAddress("to@yahoo.com", "To Name");
const string fromPassword = "password";
const string subject = "test";
const string body = "Hey now!!";
 
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword),
Timeout = 20000
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
smtp.Send(message);
}

 

 
try this code
 
Regard
Sham
Smile | :)
  Permalink  
Comments
shambhoo kumar - 3 Oct '12 - 3:39
if this is helpfull to u then accept my answer......... Regard Sham :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 159
2 Richard MacCutchan 150
3 Maciej Los 136
4 Tadit Dash 110
0 Sergey Alexandrovich Kryukov 10,264
1 OriginalGriff 7,937
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,135


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid