bulb Mail.dll faq

Show all | Hide all

Licensing

Server license:

This is per server license, you may not redistribute Mail.dll with this license.
This kind of license is valid for one server.
Your company name is embedded in this license.

Product license:

This is per product license, you may redistribute Mail.dll with your product with this license.
This kind of license is valid for one product (unlimited copies).
Your product name is embedded in this license.
You should use "License to" field during ordering process to enter your product name.

See Mail.dll buy page for details on how to buy.

Make sure that the "MailLicense.xml" file is in the run folder of your application (AppDomain.CurrentDomain.BaseDirectory).

Visual Studio 2005

In Visual Studio 2005 you can add "MailLicense.xml" file to your project, so it'll be always copied to your output directory:
  1. Right click on your project in VisualStudio in Solution Explorer.
  2. Click "Add" then "Existing item..."
  3. In "Files of type:" combo choose "All Files (*.*)".
  4. Browse to "MailLicense.xml" file and click "Add" button.
  5. Right click on "MailLicense.xml" file in Solution Explorer and click "Properties".
  6. On Properties pane change "Copy to Output Directory" option to "Copy always".

ASP.NET and ASP.NET 2.0 and WebServices

"MailLicense.xml" should be in the root folder of your web application (the folder with the "web.config" file).
Do not change this file in anyway.

General

POP3 (Post Office Protocol Version 3) is an Internet Protocol used to retrieve e-mails from a mail server. The server runs this service on TCP port 110.
SMTP (Simple Mail Transfer Protocol) is an Internet Protocol used to send e-mail messages. The server runs this service on TCP port 25.

  • Mail.dll is a .NET 2.0 assembly so it will work on .NET 2.0, 3.0 and 3.5
  • Mail.dll was tested against Mono-1.2.5.2 and works except for SSL connections (which are not implemented in Mono).
  • .NET 1.1 is no longer supported although 1.1 version exists (If you really need one send me an email)

Address fields

There may be zero or one sender: There may be many From, To, ReplyTo, Cc addresses:

"Sender" field may be null, you should use "From" field in such case.

"Sender" property is filled when message is from more than one person ("From" contains more than one mailbox). In such case it is needed to provide information which mailbox is responsible for the actual transmission.

If "From" contains only one mailbox, usually "Sender" is empty.

Each address field is a single MailBox object or a collection of MailBox objects.
Mailbox has 2 properties Address and Name.

You are probably using ToString() method which retuns only Name.

Receiving

First you have to add reference to Mail.dll in your project. See MSDN How to. Then we connect to your POP3 server, login and acquire ISimpleMailMessage using SimpleMailMessageBuilder.
First acquire ISimpleMailMessage object from POP3 server if you don't have one.
Now you should use its properties to read email data.
Click here to see all properties.
Pop3.DeleteMessage() method marks specified message for deletion. The POP3 server does not actually delete the message until the succesful QUIT command.

That is not possible with POP3 protocol. There is no way to mark on the server which messages were received by client application. You have to mark which messages have been read by yourself.

UIDL command is very helpful in achieving this goal. UIDL command returns unique-id for every message in the mailbox. You can save this id (in a custom file for example) for every message you have received.

If your ISimpleMail.Attachments collection is empty, and you are sure that there should be an attachment in your email, check Visuals collection.

Some email clients attach files as "inline" ("Content-Disposition: inline;"). That means that it should be visible to the user as soon as he/she opens an email. That's why it is in Visuals collection and not in Attachments.

First acquire ISimpleMailMessage object from POP3 server. You should use Attachments collection to get all attachments. Every attachment is represented by MimeData object.

You can also save attachment to stream: void MimeData.Save(Stream stream)
Or get direct access to it: MemoryStream MimeData.GetMemoryStream()

The email attachments are downloaded as a part of the message. Email messages follows the MIME (Multipurpose Internet Mail Extensions) standards, where in case of attachments the message headers are different. Also, the attachments are usually encoded with special encoding techniques including: Base64 and many other encoding techniques.

First acquire ISimpleMailMessage object from POP3 server. You should use Visuals collection to get all elements embedded in HTML email. For example: HTML email can contain embedded images. Every visual is represented by MimeData object.
APOP is a secure method of logging in to a POP3 mail server. Your password is encrypted while being transmitted over the network. Not all servers support APOP. The 'HasTimeStamp' property usually tells that your server supports it.
*.eml extension is standard extension used by Outlook Express.
Eml files contain raw data received from POP3 server.

Connect to POP3 server, use Pop3.GetMessage(index) to get raw email body, save it to *.eml file.
The TOP command is useful to see the headers of big emails, without downloading them.
You can always use MailMessage.Mime.Headers collection to access non-standard header:
You can send every command to POP3 server by using Mail.dll.
In this example we will issue LIST command.
LIST command is used to check the email size without downloading it from POP3 server.

There are 2 versions of the LIST command:
  1. LIST messageNumber
    We are asking for specific message. Remember that messageNumber starts from 1. In this case server reply contains only one line.
  2. You can also send LIST command to the server without any arguments, to get the size of every message.
    In this case server replies with mulit-line response.
For details on LIST and other POP3 commands visit RFC 1939.

Sending

First you have to add reference to Mail.dll in your project. See MSDN How to.
Then you have to create email message. Use SimpleMailMessage class to do this.
Then connect to your SMTP server and send your message.
Typically SMTP server is working on port 25.
Use Smtp.Connect(string host) method to connect to the server.
Use SimpleMailMessageBuilder class to create email message.
Use AddAttachment method to add a attachment the email. Then connect to SMTP server and send your message.

Use SimpleMailMessageBuilder class to create HTML email message.
Use SetHtmlData method to set the HTML code.
The AddVisual methodto add objects to attach to the created email.

Use <img src = 'cid:image1' /> syntax in HTML to access appropriate visual object.
Remember to set ContentId for added visual objects.
(E.g. image.ContentId = "image1";)

Then connect to SMTP server and send your message.
*.eml extension is standard extension used by Outlook Express.
Eml files contain raw data received from POP3 server.

To request a read receipt, we need to specify a Disposition-Notification-To header. This header is recognized my most major mail clients to send a read receipt when the email is first read. It's important to note that just because you request a read receipt, doesn't mean you will get one.

Read receipt requests may not be always honored because

  1. A mail client may not recognize the special Disposition-Notification-To header.
  2. A mail client may not implement that functionality.
  3. The end user may have that functionality turned off.
  4. The end user may optionally not choose to send one for your particular email.

Use SimpleMailMessageBuilder.AdditionalHeaders collection to add custom header.

Here's an example: Visit Mail.dll fluent interface tutorial for details.

Forwarding

SSL

Typically POP3 server is listening for SSL connections on port 995. Use Pop3.ConnectSSL(string host) method to connect using this port. You can use "Pop3.Connect(string host,int port,bool useSSL)" method for using SSL with different port.
Typically SMTP server is working on port 25 in SSL and non SSL mode, when client sends STARTTLS command, SSL connection is established. Use Smtp.Connect(string host) method to connect to the server and Smtp.StartTLS() to establish SSL connection. You can use "Smtp.ConnectSSL(string host)" method when your SMTP server is expecting SSL connections on port 465.

You can use "Smtp.Connect(string host,int port, bool useSSL)" method for using SSL with different port.
If you are using self-signed certificate or value specified for host in ConnectSSL(string host) doesn't match the name on the server's certificate you should use Pop3.ServerCertificateValidate event for custom validation.

Other

We have a special Windows control to do this - MailBrowserControl.

All you need to do is use MailBrowserControl and navigate to email message:

All images and HTML are loaded from memory - no temporary files are created.

To learn more please download Mail.dll.
Examples are installed in "Start/Lesnikowski/Mail/Examples".

or visit MailBrowserControl tutorial for details.
In case of other problems, feel free to write.
First please provide answers to this questions:
  • Check if you have the latest version installed
  • What language are you using?
  • Which example is not working correctly?
  • Which Visual Studio version are you using?
  • Which .NET Framework version are you using?
  • Is it console, windows forms, windows service or web application?
  • If it is possible please attach source code of your project (zipped).
  • If it is possible please attach zipped email message that caused an error.

Products > Mail.dll - mail component for .NET 2.0 > Mail.dll faq