Mail from WebMail to Gmail

Add Namespaces

using System.Net;
using System.Web.Mail;


MailMessage msg = new MailMessage();
msg.Body = TextBox4.Text;
string smtpServer = “smtpserver”;
string userName = “username”;
string password = “password;
int cdoBasic = 1;
int cdoSendUsingPort = 2;
if (userName.Length > 0)
msg.Fields.Add(“”, smtpServer);
msg.Fields.Add(“”, 25);
msg.Fields.Add(“”, cdoSendUsingPort);
msg.Fields.Add(“”, cdoBasic);
msg.Fields.Add(“”, userName);
msg.Fields.Add(“”, password);
msg.To = TextBox1.Text;
msg.From = TextBox2.Text;
msg.Subject =TextBox3.Text;
msg.BodyEncoding = System.Text.Encoding.UTF8;
SmtpMail.SmtpServer = smtpServer;
Label6.Text = “success”;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s