1 Introduction Printer Friendly Email This FAQ Discuss
1.1 What is System.Web.Mail? Printer Friendly Email This FAQ Discuss
1.2 What is the .NET Framework ? Printer Friendly Email This FAQ Discuss
1.3 What do I need to send email in .NET? Printer Friendly Email This FAQ Discuss
CDOSYS.DLL is part of the OS and is only installed from the OS installs. Office (Outlook actually) can optionally install CDO.DLL which System.Web.Mail does not use.
For information on the various flavors of CDO see: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/exchanchor/htms/msexchsvr_cdo_top.asp The four CDOs are (in chronological order): - CDO.DLL : CDO version 1.2.1 - CDONTS.DLL : CDO version 1.2.1 for Windows NT Server (not the same as CDO version 1.2.1!) - CDOSYS.DLL : CDO for Windows 2000 - CDOEX.DLL : CDO for Exchange 2000 Server FWIW: CDOEX.DLL is installed as part of Exchange Server installs. Jay
1.4 What is a relay server? Printer Friendly Email This FAQ Discuss
1.5 Is System.Web.Mail really a wrapper around the COM CDONTS and CDOSYS? Printer Friendly Email This FAQ Discuss
1.6 What is the IIS SMTP Service? Printer Friendly Email This FAQ Discuss
1.7 Can System.Web.Mail read email? Printer Friendly Email This FAQ Discuss
2 Quickstart Programming Samples Printer Friendly Email This FAQ Discuss
2.1 How do I send a simple email? Printer Friendly Email This FAQ Discuss
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body"; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.Body = "this is my test email body" SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.2 How do I send a simple Html email? Printer Friendly Email This FAQ Discuss
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.BodyFormat = MailFormat.Html; mail.Body = "this is my test email body.<br><b>this part is in bold</b>"; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.BodyFormat = MailFormat.Html mail.Body = "this is my test email body.<br><b>this part is in bold</b>" SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.3 How do I send an email with attachments? Printer Friendly Email This FAQ Discuss
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; MailAttachment attachment = new MailAttachment( Server.MapPath( "test.txt" ) ); //create the attachment mail.Attachments.Add( attachment ); //add the attachment SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.Body = "this is my test email body." Dim attachment As New MailAttachment(Server.MapPath("test.txt")) 'create the attachment mail.Attachments.Add(attachment) 'add the attachment SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.4 How do I change the FROM address to a friendly name? Printer Friendly Email This FAQ Discuss
mail.From = "me@mycompny.com"
mail.From = "\"John Smith\" <me@mycompny.com>"
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "\"John Smith\" <you@yourcompany.com>"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = """John Smith"" <you@yourcompany.com>" mail.Subject = "this is a test email." mail.Body = "this is my test email body." SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.5 How do I change the TO address to a friendly name? Printer Friendly Email This FAQ Discuss
mail.To = "me@mycompny.com"
mail.To = "\"Jane Doe\" <me@mycompny.com>""
MailMessage mail = new MailMessage(); mail.To = "\"Jane Doe\" <me@mycompany.com>"; mail.From = "\"John Smith\" <you@yourcompany.com>"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = """Jane Doe"" <me@mycompany.com>" mail.From = """John Smith"" <you@yourcompany.com>" mail.Subject = "this is a test email." mail.Body = "this is my test email body." SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.6 How do I specify multiple recipients? Printer Friendly Email This FAQ Discuss
mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com";
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com;him@hiscompany.com;her@hercompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.Body = "this is my test email body." SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.7 How do I add the Reply-To header to the MailMessage? Printer Friendly Email This FAQ Discuss
mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com")
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; mail.Headers.Add( "Reply-To", "alternate_email@mycompany.com" ); SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.Body = "this is my test email body." mail.Headers.Add("Reply-To", "alternate_email@mycompany.com") SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.8 How do I add custom headers to the MailMessage? Printer Friendly Email This FAQ Discuss
mail.Headers.Add( "X-Organization", "My Company LLC")
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "this is my test email body."; mail.Headers.Add( "X-Organization", "My Company LLC" ); SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "this is a test email." mail.Body = "this is my test email body." mail.Headers.Add("X-Organization", "My Company LLC") SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
2.9 How do I change the port number? Printer Friendly Email This FAQ Discuss
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/smtpserverport", "your port number"); SmtpMail.SmtpServer = "mail.mycompany.com"; SmtpMail.Send(mail);
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/smtpserverport", "your port number") 'Put port number here SmtpMail.SmtpServer = "mail.mycompany.com" 'your real server goes here SmtpMail.Send(mail)
3 Advanced Programming Samples Printer Friendly Email This FAQ Discuss
3.1 How do I send non US-ASCII emails? Printer Friendly Email This FAQ Discuss
MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "this is a test email."; mail.Body = "Some Chinese characters or text goes here"; mail.BodyEncoding = System.Text.Encoding.GetEncoding( "GB2312" ); //set the proper character set here SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail );
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 Chinese characters or text goes here" mail.BodyEncoding = System.Text.Encoding.GetEncoding("GB2312") 'set the proper character set here SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail)
3.2 How do I send a web page? Printer Friendly Email This FAQ Discuss
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."; string url = "http://www.microsoft.com"; mail.Body = HttpContent( url ); mail.BodyFormat = MailFormat.Html; mail.UrlContentBase = url; SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail ); } //screen scrape a page here private string HttpContent( string url ) { WebRequest objRequest= System.Net.HttpWebRequest.Create(url); StreamReader sr = new StreamReader( objRequest.GetResponse().GetResponseStream() ); string result = sr.ReadToEnd(); sr.Close(); return result; }
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." Dim url As String = "http://www.microsoft.com" mail.Body = HttpContent(url) mail.BodyFormat = MailFormat.Html mail.UrlContentBase = url SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail) End Sub 'Page_Load 'screen scrape a page here Private Function HttpContent(url As String) As String Dim objRequest As WebRequest = System.Net.HttpWebRequest.Create(url) Dim sr As New StreamReader(objRequest.GetResponse().GetResponseStream()) Dim result As String = sr.ReadToEnd() sr.Close() Return result End Function
3.3 How do I embed images in an email? Printer Friendly Email This FAQ Discuss
3.4 How do I email a website exception Printer Friendly Email This FAQ Discuss
protected void Application_Error(Object sender, EventArgs e) { Exception ex = Server.GetLastError(); EmailException( ex ); } private void EmailException( Exception ex ) { MailMessage mail = new MailMessage(); mail.To = "me@mycompany.com"; mail.From = "you@yourcompany.com"; mail.Subject = "An exception occurred."; mail.Body = ex.ToString(); SmtpMail.SmtpServer = "localhost"; //your real server goes here SmtpMail.Send( mail ); }
Protected Sub Application_Error(sender As [Object], e As EventArgs) Dim ex As Exception = Server.GetLastError() EmailException(ex) End Sub 'Application_Error Private Sub EmailException(ex As Exception) Dim mail As New MailMessage() mail.To = "me@mycompany.com" mail.From = "you@yourcompany.com" mail.Subject = "An exception occurred." mail.Body = ex.ToString() SmtpMail.SmtpServer = "localhost" 'your real server goes here SmtpMail.Send(mail) End Sub 'EmailException
3.5 How do I encrypt messages using s/mime or pgp? Printer Friendly Email This FAQ Discuss
3.6 How do I send multipart/related emails? Printer Friendly Email This FAQ Discuss
3.7 How do I send multipart/alternative emails? Printer Friendly Email This FAQ Discuss
3.8 How do I authenticate to send an email? Printer Friendly Email This FAQ Discuss
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 ); }
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) End Sub 'Page_Load
4 Troubleshooting System.Web.Mail Printer Friendly Email This FAQ Discuss
4.1 A Word About Exceptions (READ THIS FIRST) Printer Friendly Email This FAQ Discuss
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"; SmtpMail.SmtpServer = "mail.fake_domain.com"; //will cause an exception to be thrown try { SmtpMail.Send( mail ); } catch(Exception ex ) { Response.Write("The following exception occurred: " + ex.ToString() ); //check the InnerException while( ex.InnerException != null ) { Response.Write("--------------------------------"); Response.Write("The following InnerException reported: " + ex.InnerException.ToString() ); ex = ex.InnerException; } } }
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" SmtpMail.SmtpServer = "mail.fake_domain.com" 'will cause an exception to be thrown Try SmtpMail.Send(mail) Catch ex As Exception Response.Write(("The following exception occurred: " + ex.ToString())) 'check the InnerException While Not (ex.InnerException Is Nothing) Response.Write("--------------------------------") Response.Write(("The following InnerException reported: " + ex.InnerException.ToString())) ex = ex.InnerException End While End Try End Sub 'Page_Load
4.2 Namespace/COM/DLL Related Exceptions Printer Friendly Email This FAQ Discuss
4.2.1 Error loading type library/DLL. Printer Friendly Email This FAQ Discuss
4.2.10 "Could not access 'CDO.Message' Object - Part 8 Printer Friendly Email This FAQ Discuss
4.2.11 "Could not access 'CDO.Message' Object - Part 9 Printer Friendly Email This FAQ Discuss
4.2.12 "Could not access 'CDO.Message' Object - Part 10 Printer Friendly Email This FAQ Discuss
4.2.13 "Could not access 'CDO.Message' Object - Part 11 Printer Friendly Email This FAQ Discuss
4.2.2 The "SendUsing" configuration value is invalid. Printer Friendly Email This FAQ Discuss
SmtpMail.SmtpServer = "mail.your-domain.com"
"127.0.0.1" "localhost" "the_machine_name_here" "the_real_dns_name_here" "the_machine_IP_Address_here"
Wanted to provide some additional information regarding a topic you have listed on SMTP and the SendUsing parameter. Issue: Number=-2147220502(0x800403EA) App [1002] Source=CDO.Message.1 Description= -2147220960[0x80040220]The "SendUsing" configuration value is invalid. Additional Cause: The account running the code (usually a COM+ packaged component) which calls CDO (SMTP) does not have permissions to access the SendUsing configuration of the SMTP Metabase. Additional Resolution: Run the adadd.vbs with the user account running the component code calling CDO.
4.2.3 The scary "Could not access 'CDO.Message' object" Printer Friendly Email This FAQ Discuss
SmtpMail.SmtpServer = "127.0.0.1"
SmtpMail.SmtpServer.Insert( 0, "127.0.0.1 or your mail server name here")
4.2.4 "Could not access 'CDO.Message' Object - Part 2 Printer Friendly Email This FAQ Discuss
OPTION EXPLICIT Dim obj, acl, ace, aspNetAce Set obj = GetObject("IIS://localhost/SMTPSVC") Set acl = obj.AdminAcl Dim aspNetAcePresent : aspNetAcePresent = false ' Find "machine\ASPNET" access control entry For Each ace in acl.DiscretionaryACL If endsWith(ace.Trustee, "\ASPNET") Then aspNetAcePresent = True Exit For End If Next If Not aspNetAcePresent Then Set ace = CreateObject("AccessControlEntry") ace.Trustee = "ASPNET" ace.AccessMask = &H1 ' Read access acl.DiscretionaryACL.AddAce ace ' Save changes obj.AdminAcl = acl obj.SetInfo WScript.Echo "ASPNET account granted Read access to 'IIS://localhost/SMTPSVC'." Else WScript.Echo "ASPNET account already has access to 'IIS://localhost/SMTPSVC'." End If '========================================================== Function endsWith(str1, suffix) EndsWith = (Mid(str1,Len(str1)-Len(suffix)+1) = suffix) End Function
4.2.5 "Could not access 'CDO.Message' Object - Part 3 Printer Friendly Email This FAQ Discuss
4.2.6 "Could not access 'CDO.Message' Object - Part 4 Printer Friendly Email This FAQ Discuss
4.2.7 "Could not access 'CDO.Message' Object - Part 5 Printer Friendly Email This FAQ Discuss
4.2.8 "Could not access 'CDO.Message' Object - Part 6 Printer Friendly Email This FAQ Discuss
Thanks for your very useful web site at http://www.systemwebmail.com. I too have just been struggling with the scary "Could not access 'CDO.Message' object" error. Wanted to share my solution so you can add it to your list of suggestions.
Here's the exception we were getting:
System.Exception: Unable to send mail: Could not access 'CDO.Message' object. ---> System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80004005): Unspecified error
--- End of inner exception stack trace --- at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) --- End of inner exception stack trace --- at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail.SmtpMail.Send(MailMessage message) at MyApp.MyApp.Util.SendEmail(MailMessage& objMail) --- End of inner exception stack trace --- at MyApp.MyApp.Util.SendEmail(MailMessage& objMail) at MyApp.MI.btnServerSave_Click(Object sender, EventArgs e) --------
Here's the setup: ASP.Net web application using local SMTP mail service to send emails, some with attachments, some without attachments. Web app set to use Windows integrated security with impersonation, so web.config has these entries:
<authentication mode="Windows" /> <identity impersonate="true" />
All worked fine until we went to the email attachments. Either the "unspecified error" exception was thrown, or on other servers the email was sent but the attachments were corrupted. GIFs, TIFs, PDFs, you name it. Turns out that when handling email attachments, CDO does not entirely assume the impersonation identity. Instead, the aspnet_wp.exe process identity defined in machine.config comes into play, same as it would if you were using anonymous access. This process needs to create its own temp directory, found on my machine under c:\Documents and Settings\\ASPNET\Local Settings. Then the authenticated users need to be able to access this as well. So we granted permissions on that dir to my MYDOMAIN\myusergroup. Problem solved!
Useful background found in Microsoft KB # 317012: http://support.microsoft.com/default.aspx?scid=kb;en-us;317012
4.2.9 "Could not access 'CDO.Message' Object - Part 7 Printer Friendly Email This FAQ Discuss
Could not access 'CDO.Message' object. innerexception: The transport failed to connect to the server. Setting SmtpMail.SmtpServer using the IP address gives: Could not access 'CDO.Message' object. innerexception: The message could not be sent to the SMTP server. The transport error code was 0x800ccc15. The server response was not available
4.3 SMTP Protocol/Network Related Exceptions Printer Friendly Email This FAQ Discuss
4.3.1 The server specified in the SmtpServer property is not valid or not available Printer Friendly Email This FAQ Discuss
SmtpMail.SmtpServer
4.3.10 Can send locally but not externally. Printer Friendly Email This FAQ Discuss
4.3.11 550 x.x.x Unable to relay for xxxxx. Printer Friendly Email This FAQ Discuss
4.3.2 [COMException (0x8004020f): The server rejected one or more recipient addresses."] Printer Friendly Email This FAQ Discuss
4.3.3 Some of emails are rejected by some clients, but not all. Printer Friendly Email This FAQ Discuss
4.3.4 My mail server requires authentication. (503 This mail server requires authentication) Printer Friendly Email This FAQ Discuss
4.3.5 Not a gateway or local host. Printer Friendly Email This FAQ Discuss
4.3.6 The specified protocol is unknown. Printer Friendly Email This FAQ Discuss
4.3.7 The specified protocol is unknown. Part 2 Printer Friendly Email This FAQ Discuss
4.3.8 The server response was 452 Filesystem error - message not accepted. Printer Friendly Email This FAQ Discuss
4.3.9 The transport failed to connect to the server. Printer Friendly Email This FAQ Discuss
4.4 Other Problems/Exceptions Printer Friendly Email This FAQ Discuss
4.4.1 How can I stream attachments into the MailMessage? Printer Friendly Email This FAQ Discuss
4.4.2 How can I create an attachment from a string? Printer Friendly Email This FAQ Discuss
4.4.3 Why does System.Web.Mail work in development and not in production? Printer Friendly Email This FAQ Discuss
4.4.4 I keep getting question marks (?'s) in my email, where characters should be. Printer Friendly Email This FAQ Discuss
4.4.5 System.Web.Mail is truncating the message body. Printer Friendly Email This FAQ Discuss
4.4.6 Attachments added to the MailMessge are corrupt. Printer Friendly Email This FAQ Discuss
MailAttachment attachment = new MailAttachment( "test.txt", MailEncoding.Base64) or MailAttachment attachment = new MailAttachment( "test.txt", MailEncoding.UUEncode)
4.4.7 All of my emails are ending up in the /badmail directory. Printer Friendly Email This FAQ Discuss
Diagnostic-Code: smtp;554 Service unavailable; Client host [xxx.xxx.xxx.xxx] blocked using dnsbl.njabl.org (or some other Open Relay Database )
Unable to connect to transport….
4.4.8 System.Web.Mail is corrupting my PDF attachments, what gives? Printer Friendly Email This FAQ Discuss
MailMessage m = new MailMessage(); m.From = "dave@aspnetemail.com"; m.To = "dave@aspnetemail.com"; m.Subject = "period test"; m.Body= "this \r\n. is a test"; MailAttachment a = new MailAttachment( "c:\\test.txt" ); m.Attachments.Add( a ); SmtpMail.Send( m );
Dim m As New MailMessage() m.From = "dave@aspnetemail.com" m.To = "dave@aspnetemail.com" m.Subject = "period test" m.Body = "this " + ControlChars.Cr + ControlChars.Lf + ". is a test" Dim a As New MailAttachment("c:\test.txt") m.Attachments.Add(a) SmtpMail.Send(m)
5 Additional Resources Printer Friendly Email This FAQ Discuss
5.1 Community Help Printer Friendly Email This FAQ Discuss
5.1.1 Yahoo .NET Email List Printer Friendly Email This FAQ Discuss
5.1.2 Aspadvice ASP.NET Lists Printer Friendly Email This FAQ Discuss
5.1.3 Microsoft Newsgroups Printer Friendly Email This FAQ Discuss
5.2 Other Helpful Links Printer Friendly Email This FAQ Discuss
5.2.1 Email tutorials on www.123aspx.com Printer Friendly Email This FAQ Discuss
5.2.10 HOWTO: Send E-mail Programmatically with System.Web.Mail and Visual C# .NET Printer Friendly Email This FAQ Discuss
5.2.11 Periods at the Beginning of a Line Are Removed When Placed into the SMTP Pickup Directory Printer Friendly Email This FAQ Discuss
5.2.2 SMTP server and email FAQ at the ASP.NET Forums Printer Friendly Email This FAQ Discuss
5.2.3 System.Web.Mail Namespace Printer Friendly Email This FAQ Discuss
5.2.4 Manage Your Company's E-mail with the Windows 2000 SMTP Service Printer Friendly Email This FAQ Discuss
5.2.5 XCON: Cannot Send E-Mail Messages to a Growing List of Domains Printer Friendly Email This FAQ Discuss
5.2.6 Read Access to the Everyone Group Is Removed After You Install Exchange 2000 SP3 Printer Friendly Email This FAQ Discuss
5.2.7 HOWTO: Use CDO (1.x) to Set Up Reply to Alternate Recipient Printer Friendly Email This FAQ Discuss
5.2.8 INFO: Process and Request Identity in ASP.NET Printer Friendly Email This FAQ Discuss
5.2.9 PRB: Collaboration Data Objects for Windows NT, Collaboration Data Objects for Windows 2000, and Collaboration Data Objects for Exchange 2000 Require Outlook Express Printer Friendly Email This FAQ Discuss
6 RFCs for sending, receiving, and parsing email. Printer Friendly Email This FAQ Discuss
6.1 Send (SMTP) Email RFCs Printer Friendly Email This FAQ Discuss
6.1.1 RFC 2821 Simple Mail Transfer Protocol (SMTP) Printer Friendly Email This FAQ Discuss
6.1.10 RFC 2852 Deliver By SMTP Service Extension Printer Friendly Email This FAQ Discuss
6.1.11 RFC 2034 SMTP Service Extension for Returning Enhanced Error Codes Printer Friendly Email This FAQ Discuss
6.1.12 RFC 3463 Enhanced Mail System Status Codes Printer Friendly Email This FAQ Discuss
6.1.13 RFC 3461 SMTP Service Extension for Delivery Status Notifications Printer Friendly Email This FAQ Discuss
6.1.14 RFC 3462 Multipart/Report Content Type for the Reporting of Mail System Administrative Messages Printer Friendly Email This FAQ Discuss
6.1.15 RFC 2554 SMTP Service Extension for Authentication Printer Friendly Email This FAQ Discuss
6.1.16 RFC 2505 Anti-Spam Recommendations for SMTP MTAs Printer Friendly Email This FAQ Discuss
6.1.17 RFC 2442 Batch SMTP Media Type Printer Friendly Email This FAQ Discuss
6.1.18 RFC 1047 Duplicate messages and SMTP Printer Friendly Email This FAQ Discuss
6.1.2 RFC 974 Mail routing and the domain system (MX records) Printer Friendly Email This FAQ Discuss
6.1.3 RFC 1869 SMTP Service Extensions Printer Friendly Email This FAQ Discuss
6.1.4 RFC 1870 SMTP Service Extension for Message Size Declaration Printer Friendly Email This FAQ Discuss
6.1.5 RFC 1652 SMTP Service Extension for 8bit-MIMEtransport Printer Friendly Email This FAQ Discuss
6.1.6 RFC 3030 SMTP Service Extensions for Transmission of Large and Binary MIME Messages Printer Friendly Email This FAQ Discuss
6.1.7 RFC 1846 SMTP 521 Reply Code Printer Friendly Email This FAQ Discuss
6.1.8 RFC 1985 SMTP Service Extension for Remote Message Queue Starting (ETRN) Printer Friendly Email This FAQ Discuss
6.1.9 RFC 2645 On-Demand Mail Relay (ODMR) SMTP with Dynamic IP Addresses Printer Friendly Email This FAQ Discuss
6.2 Receiving (POP3/IMAP) Email RFCs Printer Friendly Email This FAQ Discuss
6.2.1 RFC 2298 Extensible Message Format for Message Disposition Notifications (MDNs) Printer Friendly Email This FAQ Discuss
6.2.10 RFC 1731 IMAP4 Authentication Mechanisms Printer Friendly Email This FAQ Discuss
6.2.11 RFC 2342 IMAP4 Namespace Printer Friendly Email This FAQ Discuss
6.2.12 RFC 2359 IMAP4 UIDPLUS extension Printer Friendly Email This FAQ Discuss
6.2.13 RFC 3348 IMAP4 Child Mailbox Extension Printer Friendly Email This FAQ Discuss
6.2.14 RFC 2683 IMAP4 Implementation Recommendations Printer Friendly Email This FAQ Discuss
6.2.15 RFC 2971 IMAP4 ID extension Printer Friendly Email This FAQ Discuss
6.2.16 RFC 3502 IMAP MULTIAPPEND Extension Printer Friendly Email This FAQ Discuss
6.2.17 RFC 3503 Message Disposition Notification (MDN) profile for IMAP Printer Friendly Email This FAQ Discuss
6.2.18 RFC 3516 IMAP4 Binary Content Extension Printer Friendly Email This FAQ Discuss
6.2.19 RFC 2476 Message Submission Printer Friendly Email This FAQ Discuss
6.2.2 RFC 1939 Post Office Protocol - Version 3 (POP3) Printer Friendly Email This FAQ Discuss
6.2.20 RFC 2244 ACAP -- Application Configuration Access Protocol Printer Friendly Email This FAQ Discuss
6.2.21 RFC 1056 PCMAIL: A distributed mail system for personal computers Printer Friendly Email This FAQ Discuss
6.2.22 RFC 1204 Message Posting Protocol (MPP) Printer Friendly Email This FAQ Discuss
6.2.23 RFC 1339 Remote Mail Checking Protocol Printer Friendly Email This FAQ Discuss
6.2.3 RFC 1734 - POP3 AUTHentication command Printer Friendly Email This FAQ Discuss
6.2.4 RFC 1957 Some Observations on Implementations of POP3 Printer Friendly Email This FAQ Discuss
6.2.5 RFC 2384 POP URL Scheme Printer Friendly Email This FAQ Discuss
6.2.6 RFC 2449 POP3 Extension Mechanism Printer Friendly Email This FAQ Discuss
6.2.7 RFC 3206 SYS and AUTH POP Response Codes Printer Friendly Email This FAQ Discuss
6.2.8 RFC 2195 IMAP/POP AUTHorize Extension for Simple Challenge/Response Printer Friendly Email This FAQ Discuss
6.2.9 RFC 3501 Internet Message Access Protocol - version 4rev1(IMAP4) Printer Friendly Email This FAQ Discuss
6.3 Parsing (MIME/Multipart Messages) Email RFCs Printer Friendly Email This FAQ Discuss
6.3.1 RFC 2822 Internet Message Format Printer Friendly Email This FAQ Discuss
6.3.10 RFC 2049 MIME Part 5: Conformance Criteria and Examples Printer Friendly Email This FAQ Discuss
6.3.11 RFC 2183 Communicating Presentation Information in Internet Messages: The Content-Disposition Header Printer Friendly Email This FAQ Discuss
6.3.12 RFC 2557 MIME Encapsulation of Aggregate Documents, such as HTML (MHTML) Printer Friendly Email This FAQ Discuss
6.3.13 RFC 2854 text/html Media Type Printer Friendly Email This FAQ Discuss
6.3.14 RFC 2392 Content-ID and Message-ID Uniform Resource Locators Printer Friendly Email This FAQ Discuss
6.3.15 RFC 2646 Text/Plain Format Parameter Printer Friendly Email This FAQ Discuss
6.3.16 RFC 2387 MIME Multipart/Related Content-type Printer Friendly Email This FAQ Discuss
6.3.17 RFC 3066 Tags for the Identification of Languages Printer Friendly Email This FAQ Discuss
6.3.18 RFC 2231 MIME Parameter Value and Encoded Word Extensions: Character Sets, Languages, and Continuations Printer Friendly Email This FAQ Discuss
6.3.19 RFC 2017 Definition of the URL MIME External-Body Access-Type Printer Friendly Email This FAQ Discuss
6.3.2 RFC 2076 Common Internet Message Headers Printer Friendly Email This FAQ Discuss
6.3.20 RFC 2388 Returning Values from Forms: multipart/form-data Printer Friendly Email This FAQ Discuss
6.3.21 RFC 2376 XML Media Types Printer Friendly Email This FAQ Discuss
6.3.22 RFC 1556 Handling of Bi-directional Texts in MIME Printer Friendly Email This FAQ Discuss
6.3.23 RFC 1524 User Agent Configuration Mechanism For Multimedia Mail Format Information Printer Friendly Email This FAQ Discuss
6.3.24 RFC 1896 MIME text/enriched content-type Printer Friendly Email This FAQ Discuss
6.3.25 RFC 1428 Transition of Internet Mail from Just-Send-8 to 8bit-SMTP/MIME Printer Friendly Email This FAQ Discuss
6.3.26 RFC 1740 MIME Encapsulation of Macintosh Files (MacMIME) Printer Friendly Email This FAQ Discuss
6.3.27 RFC 1741 MIME Content Type for BinHex Encoded Files Printer Friendly Email This FAQ Discuss
6.3.28 RFC 1767 MIME Encapsulation of EDI Objects Printer Friendly Email This FAQ Discuss
6.3.29 RFC 1844 Multimedia E-mail (MIME) User Agent Checklist Printer Friendly Email This FAQ Discuss
6.3.3 RFC 1153 Digest message format Printer Friendly Email This FAQ Discuss
6.3.30 RFC 1864 Content-MD5 Header Field Printer Friendly Email This FAQ Discuss
6.3.31 RFC 2077 The Model Primary Content Type for MIME Printer Friendly Email This FAQ Discuss