You can use following code to forward an email message downloaded from IMAP, of course you need to use SMTP for sending:
IMail original = GetFirstMessage();
ForwardBuilder forwardBuilder = original.Forward();
forwardBuilder.Html = "Tom, <br/><br/>please resolve this.";
MailBuilder builder = forwardBuilder.Forward(new MailBox("bob@example.org", "Bob"));
builder.To.Add(new MailBox("tom@example.org", "Tom"));
// You can add attachments to forwarded email:
//builder.AddAttachment("report.csv");
IMail forward = builder.Create();
using (Smtp smtp = new Smtp())
{
smtp.Connect("smtp.example.org"); // or ConnectSSL
smtp.UseBestLogin("user", "password");
smtp.SendMessage(forward);
smtp.Close();
}
static IMail GetFirstMessage()
{
IMail email;
using (Imap imap = new Imap())
{
imap.Connect("imap.example.com"); // or ConnectSSL if you want to use SSL
imap.UseBestLogin("user", "password");
List<long> uids = imap.GetAll();
if (uids.Count == 0)
throw new Exception("There are no messages");
var eml = imap.GetMessageByUID(uids[0]);
email = new MailBuilder().CreateFromEml(eml);
imap.Close();
}
return email;
}
You can learn how to specify your own, custom, body and subject templates here:
https://www.limilabs.com/blog/forward-email