3
votes

I want to forward an existing Email from my Outlook inbox folder. On recent research I found some different solutions:

  • get the current mail item and copy it to a new message
  • move method to move in a different folder
  • forward method...

My goal is to find a simple way to forward an existing Email to another E-Mail adress.

My code enclosed does not have access to send!

private void buttonExplorer_Click(object sender, RibbonControlEventArgs e)
{
    Microsoft.Office.Interop.Outlook.Selection mySelection = Globals.ThisAddIn.Application.ActiveExplorer().Selection;
    Microsoft.Office.Interop.Outlook.MailItem mailItem = null;
    foreach (Object obj in mySelection)
    {
        if (obj is Microsoft.Office.Interop.Outlook.MailItem)
        {
            mailItem = (Microsoft.Office.Interop.Outlook.MailItem)obj;
            mailItem.Forward();
            mailItem.Recipients.Add("[email protected]");
            mailItem.Send();
        }
    }
}

Would be nice if there is a simple way to solve the forwarding event issue.

2

2 Answers

3
votes

Forward() creates a new item, as stated here.

So you'll need to use that new item from then on:

var newItem = mailItem.Forward();
newItem.Recipients.Add("[email protected]");
newItem.Send();
-1
votes

Try using Microsoft Exchange Web Service (EWS) to forward the email messages. EWS provides api for the commonly used events.

A sample code would like this,

// Connect to Exchange Web Services as user1 at contoso.com.
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
service.Credentials = new WebCredentials("[email protected]", "password ");
service.AutodiscoverUrl("[email protected]");

// Create the e-mail message, set its properties, and send it to [email protected], saving a copy to the Sent Items folder. 
EmailMessage message = new EmailMessage(service);
message.Subject = "Interesting";
message.Body = "The proposition has been considered."; 
message.ToRecipients.Add("[email protected]");
message.SendAndSaveCopy();

For more info, refer https://msdn.microsoft.com/en-us/library/office/dd633681(v=exchg.80).aspx