Customer Support Center Language
 
Home Knowledge Base E-mail & Webmail Send email using my email user credentials through the CDOSYS component
Information
Article ID102
Created On7/17/2008
Modified7/17/2008
Share With Others
Send email using my email user credentials through the CDOSYS component

The following example demonstrates sending your username and password to the SMTP server to provide authentication.

[ C# ]
private void Page_Load(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "
me@mycompany.com";
mail.From = "
you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.Body = "Some text goes here";
mail.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here"); //set your username here
mail.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret"); //set your password here SmtpMail.SmtpServer = "mail.mycompany.com"; //your real server goes here
SmtpMail.Send( mail );
}

[ VB.NET ]
Private Sub Page_Load(sender As Object, e As System.EventArgs)
Dim mail As New MailMessage()
mail.To = "
me@mycompany.com"
mail.From = "
you@yourcompany.com"
mail.Subject = "this is a test email."
mail.Body = "Some text goes here"
mail.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
mail.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendusername", "my_username_here") 'set your username here
mail.Fields.Add("
http://schemas.microsoft.com/cdo/configuration/sendpassword", "super_secret") 'set your password here
SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here
SmtpMail.Send(mail)