Click here to Skip to main content
11,492,962 members (60,354 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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 20:00pm
Edited 2-Oct-12 20:12pm
Mehdi Gholam276.3K
v3
Comments
Abhijit Parab at 3-Oct-12 1:04am
   
what error it shows?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 at 3-Oct-12 3:39am
   
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
0 Sergey Alexandrovich Kryukov 419
1 Maciej Los 286
2 F-ES Sitecore 224
3 KarstenK 210
4 CPallini 208
0 Sergey Alexandrovich Kryukov 10,132
1 OriginalGriff 8,630
2 Sascha Lefèvre 3,624
3 Maciej Los 3,392
4 Richard Deeming 2,500


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 3 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100