Use the Add
method of Attachments
collection as in following code:
// create a mail message and add attachment to it
MailMessage message = new MailMessage()
message.Attachments.Add(new Attachment("c:\\data.zip"))
Following code will fill values for some basic properties and will upload the message to the server via IMAP:
message.From = "from@example.org"
message.To = "to@example.org"
message.Subject = "Mail subject"
Imap client = new Imap()
client.Connect("imap.example.org")
client.Login("username", "password")
// upload the message into Inbox
client.StoreMessage("Inbox", mail)
You may also find following tutorials handy: