I am fairly new to C# as well as the Outlook Library. I've spent the past two weeks searching around reading documentation and examples yet I can't seem to achieve this simple (or so it seems) task.
The Intention:
The idea is to have a custom button that only appears in the ribbon of the New Mail window and when clicked, will prompt the user to choose an Outlook Folder. After the user chooses a folder and clicks OK, it will send the email and save a copy in the specified folder as well as the sent folder.
I am aware that currently, it is possible to specify which folder you want to save the outgoing message in. However, this will only save a copy in the specified folder, and not an additional copy in the Sent Items folder.
The Current Situation:
What I have currently will make a copy of the current email, move it to the specified folder, and send the original. However, the copied email will not show up as an email that's been sent. It is still editable which is not exactly what I am aiming for.
private void button1_Click(object sender, RibbonControlEventArgs e) {
MessageBox.Show("Save and Send button was clicked.");
Outlook.Application application = new Outlook.Application();
Outlook.Explorer explorer = application.ActiveExplorer();
Outlook.Inspector inspector = application.ActiveInspector();
Outlook._MailItem mailItem = inspector.CurrentItem;
Outlook.NameSpace nameSpace = application.GetNamespace("MAPI");
MessageBox.Show("Select a location to save the email");
Outlook.MAPIFolder folder = (Outlook.Folder)nameSpace.PickFolder();
Outlook._MailItem newMailCopy = mailItem.Copy();
newMailCopy.Move(folder);
mailItem.Send();
MessageBox.Show(newMailCopy + " was copied to " + folder);
}
I am creating a Ribbon (Visual Designer) in Visual Studio 2013 for an Outlook 2013 Add-In. What would be the best way to do this in C#?
Any help would be greatly appreciated! Regards,