SmtpAddAttachment Method |
Namespace: MailBee.SmtpMail
Exception | Condition |
---|---|
MailBeeException | An error occurred and ThrowExceptions is true. |
Smtp.AddAttachment method is equivalent to Smtp.Message.Attachments.Add method (see Add(String)).
The developer can use overloads of Add(Attachment) method to add attachments in an advanced way (memory or stream attachments, attachments of a specific type, etc).
Note |
---|
If you send multiple messages reusing the same Message object, be sure to clear Attachments collection of Message object by calling Clear method after each send. Otherwise, the attachments added to the collection during send operation will still remain in the collection when new attachments are added for the next send operation. |
// To use the code below, import MailBee namespaces at the top of your code. using MailBee; using MailBee.SmtpMail; // The actual code (put it into a method of your class) Smtp mailer = new Smtp(); // Add attachment under real name. mailer.AddAttachment(@"C:\My Documents\Report.xls"); // Add B4DVIS9H.TMP file as "Annual report.doc". mailer.Message.Attachments.Add(@"C:\DataFiles\B4DVIS9H.TMP", "Annual report.doc");