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(“http://schemas.microsoft.com/cdo/configuration/smtpserver”, smtpServer);
msg.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpserverport”, 25);
msg.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusing”, cdoSendUsingPort);
msg.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/smtpauthenticate”, cdoBasic);
msg.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendusername”, userName);
msg.Fields.Add(“http://schemas.microsoft.com/cdo/configuration/sendpassword”, password);
}
msg.To = TextBox1.Text;
msg.From = TextBox2.Text;
msg.Subject =TextBox3.Text;
msg.BodyEncoding = System.Text.Encoding.UTF8;
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(msg);
Label6.Text = “success”;


0 comments:
Post a Comment
Note: only a member of this blog may post a comment.