DotNetOpenMail

 

 • Home

 • Overview

 • Examples

 • More Examples

 • Documentation

 • Download

 • Changelog

 • Project Home

 • Forums

 • Announcements

SourceForge.net Logo

Support This Project

Examples

 

Create an email in an alternate encoding:

				
	System.Text.Encoding encoding=System.Text.Encoding.GetEncoding("Shift_JIS");
	
	// setting an encoding and chartype here will encode the name 
	// (but not the email address itself).
	EmailAddress japanesefromaddress = new EmailAddress("kawabata@XXXXXXX.com", 
		"川端康成", EncodingType.Base64, encoding);
	EmailAddress japanesetoaddress = new EmailAddress("mifune@XXXXXXX.com", 
		"三船敏郎", EncodingType.Base64, encoding);
		
	EmailMessage emailmessage=new EmailMessage();

	// The header encoding and charset specifies how to encode the 
	// non-ascii headers.
	emailmessage.HeaderEncoding = DotNetOpenMail.Encoding.EncodingType.Base64;
	emailmessage.HeaderCharSet = System.Text.Encoding.GetEncoding("Shift_JIS");

	emailmessage.FromAddress = japanesefromaddress;
	emailmessage.AddToAddress(japanesetoaddress);
	emailmessage.Subject = "日本語 - Base 64 encoded";

	emailmessage.TextPart = new TextAttachment("日本語 日本語");
	emailmessage.TextPart.CharSet = System.Text.Encoding.GetEncoding("Shift_JIS");
	emailmessage.TextPart.Encoding = DotNetOpenMail.Encoding.EncodingType.Base64;

	emailmessage.HtmlPart = new HtmlAttachment("<html><body>日本語 日本語</body></html>");
	emailmessage.HtmlPart.CharSet = System.Text.Encoding.GetEncoding("Shift_JIS");
	emailmessage.HtmlPart.Encoding = DotNetOpenMail.Encoding.EncodingType.Base64;

	emailmessage.Send(_smtpserver);