MailMessageForwardAsAttachment Method |
Forwards a mail message as attached .EML file.
Namespace: MailBee.MimeAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public MailMessage ForwardAsAttachment()
Public Function ForwardAsAttachment As MailMessage
Return Value
Type:
MailMessage
A new
MailMessage object containing the message as attached .EML file.
Remarks
This method constructs a new e-mail message and adds original message as an attachment, all other fields of the new message remain empty (such as Subject, Body, To, Cc and Bcc fields, etc).
Examples This sample loads the message from .EML file, forwards it as attachment and sends the resulting message out.
using MailBee;
using MailBee.SmtpMail;
using MailBee.Mime;
class Sample
{
static void Main(string[] args)
{
MailMessage msg = new MailMessage();
msg.LoadMessage(@"C:\Docs\msg.eml");
MailMessage newMsg = msg.ForwardAsAttachment();
newMsg.From.AsString = "John Doe <jdoe@domain.com>";
newMsg.To.AsString = "Alice <al@company.com>";
newMsg.Subject = "Forwarded message";
newMsg.BodyPlainText = "The message is attached.";
Smtp.QuickSend(newMsg);
}
}
Imports MailBee
Imports MailBee.SmtpMail
Imports MailBee.Mime
Module Sample
Sub Main(ByVal args As String())
Dim msg As New MailMessage
msg.LoadMessage("C:\Docs\msg.eml")
Dim newMsg As MailMessage = msg.ForwardAsAttachment()
newMsg.From.AsString = "John Doe <jdoe@domain.com>"
newMsg.To.AsString = "Alice <al@company.com>"
newMsg.Subject = "Forwarded message"
newMsg.BodyPlainText = "The message is attached."
Smtp.QuickSend(newMsg)
End Sub
End Module
See Also