Click here to Skip to main content
15,172,351 members
Articles / Web Development / ASP.NET
Posted 12 Dec 2003


70 bookmarked

SMTP Authentication using System.Web.Mail (CDOSYS)

Rate me:
Please Sign up or sign in to vote.
4.75/5 (49 votes)
12 Dec 2003
Setting CDOSYS Schema contents to permit "tricks" with System.Web.Mail


SMTP Authentication - expensive third party control or roll-you-own with System.Net and sockets? Not required: The CDOSYS Schema is accessible directly from your code and you can use MailMessage.Fields to access and change schema values to control the attributes of your email.

Using the code

Create your email using the MailMessage class - then set the Schema Fields of Interest to you. For example, to send via an external SMTP server on port 25 with SMTP authentication name and password:

// using System.Web.Mail;
    eMail = new MailMessage();
    eMail.BodyFormat = MailFormat.Text;
    eMail.From = _SendFrom;
      = "SMTPServerName";
""] = 25;
""]  = 2;
    if (SMTPUser != null && SMTPPassword != null)
""] = 1;
""] = 
""] = 
    eMail.To = "recipients";
    SmtpMail.SmtpServer = SMTPServerName;

Check MSDN for the CDOSYS and enumerated values.



This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

United Kingdom United Kingdom
No Biography provided

Comments and Discussions

QuestionHow to send email to a Group Pin
AJFK1-Oct-09 9:51
MemberAJFK1-Oct-09 9:51 
Generalmails are queued in queue directory. Pin
rajeshchavan19838-Jul-09 3:51
Memberrajeshchavan19838-Jul-09 3:51 
QuestionWhat about saved password in Outlook Express ? Pin
blackjack200810-Jun-09 3:13
Memberblackjack200810-Jun-09 3:13 
GeneralSave mail in Sent items Pin
Pardeep Bogra16-Jun-08 4:36
MemberPardeep Bogra16-Jun-08 4:36 
QuestionBulk Emails: Does anyone know how to send multiple emails inside one connect/disconnect? Pin
remoteportal17-Apr-08 5:38
Memberremoteportal17-Apr-08 5:38 
GeneralError 451? Fix is here! Pin
md2k8-Aug-07 3:10
Membermd2k8-Aug-07 3:10 
GeneralIf you are having issues with authentication you want to read this... Pin
BrotherC31-Jan-07 10:04
MemberBrotherC31-Jan-07 10:04 
GeneralRe: If you are having issues with authentication you want to read this... Pin
hepsy.i26-Oct-07 0:58
Memberhepsy.i26-Oct-07 0:58 
GeneralTo/From Addresses in ASP.NET Email Sending Pin
f.z25-Dec-06 10:59
Memberf.z25-Dec-06 10:59 
Generalh Pin
Farhan Hashmi27-Nov-06 14:08
MemberFarhan Hashmi27-Nov-06 14:08 
GeneralThis Code Does not work.... Help Me out.... Pin
nilsgate22-Jun-06 1:20
Membernilsgate22-Jun-06 1:20 
GeneralRe: This Code Does not work.... Help Me out.... Pin
wsdelicate28-Jun-06 8:36
Memberwsdelicate28-Jun-06 8:36 
GeneralRe: SMTP Authentication using System.Web.Mail (CDOSYS) Pin
malharone8-Nov-05 7:25
Membermalharone8-Nov-05 7:25 
QuestionDoes anyone know where the cdosys schema has moved? Pin
daniel1122334-Nov-05 8:07
Memberdaniel1122334-Nov-05 8:07 
AnswerRe: Does anyone know where the cdosys schema has moved? Pin
jamiranda21-Dec-05 4:34
Memberjamiranda21-Dec-05 4:34 
Generalthank you!!!! Pin
ansys17-Jun-05 19:43
Memberansys17-Jun-05 19:43 
Generalthank you Pin
fatibomba7-Apr-05 1:47
Memberfatibomba7-Apr-05 1:47 
GeneralUsing C++ Pin
adrianodri10-Dec-04 2:08
Memberadrianodri10-Dec-04 2:08 
GeneralFantastic! Pin
JayDreyer23-Sep-04 11:04
MemberJayDreyer23-Sep-04 11:04 
GeneralError No 451 Pin
Anonymous31-Jul-04 23:15
MemberAnonymous31-Jul-04 23:15 
GeneralExternal SMTP Server with CDOSYS Pin
ramesh_n330-Jun-04 13:46
Memberramesh_n330-Jun-04 13:46 
GeneralRe: External SMTP Server with CDOSYS Pin
fulgeras13-Jan-05 23:34
Memberfulgeras13-Jan-05 23:34 
GeneralRe: External SMTP Server with CDOSYS Pin
Anonymous17-Aug-05 1:49
MemberAnonymous17-Aug-05 1:49 
GeneralRe: External SMTP Server with CDOSYS Pin
Anonymous17-Aug-05 1:53
MemberAnonymous17-Aug-05 1:53 
QuestionCan't connect? Pin
Adrian ~ Foobar Software22-Apr-04 1:58
MemberAdrian ~ Foobar Software22-Apr-04 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.