c# download outlook msg file attachment
Microsoft.Office.Interop.Outlook.Application oOutlookApp = new Microsoft.Office.Interop.Outlook.Application();
MailItem oMailItem = null;
oMailItem = oOutlookApp.CreateItemFromTemplate("e:\\test.msg");
Attachments oAttachments = oMailItem.Attachments;
for (int i = 1; i <= oAttachments.Count; i++)
{
Attachment oAttachment = oAttachments[i];
oAttachment.SaveAsFile(AppDomain.CurrentDomain.BaseDirectory + oAttachment.FileName);
Marshal.ReleaseComObject(oAttachment);
oAttachment = null;
}
Marshal.ReleaseComObject(oAttachments);
oAttachments = null;
Marshal.ReleaseComObject(oMailItem);
oMailItem = null;
oOutlookApp.Quit();
Marshal.ReleaseComObject(oOutlookApp);
oOutlookApp = null;
Also in C#:
- run async method parallel c#
- c# build string out of list of strings
- c# enum.getvalues
- c# null conditional operator if statement
- c# list remove item based on property duplicate
- serilog loglevel order
- c# function
- matplotlib measure the width of text
- how to detected WindowCloseEvent in other window wpf
- c# lambda expression
- download file from url asp net web api c#
- c# LCP
- how to mock abstract httpcontext using moq .net core
- wpf use enum description
- repeat 10 timesw c#
- unity separator in inspector
- when do i need to end a sentence with ; in c#
- unity rotate around point
- unity if gameobject exists
- 2d object look at object
- c# razor add disabled to button if
- how to make game unity c#
- c sharp tryparse
- git set origin