Last post Jun 26, 2020 02:37 AM by samwu
Jun 25, 2020 03:08 PM|Rakib Ahmed|LINK
Dear Programmers, Is anybody worked about extracting email attachment from outlook email and read that attachment. i mean my goal is to first to read email attachment from outlook email and then read attachment file like txt file and save that txt file information.
if anybody worked with this kindly give me direction. I found this below link https://www.matthewproctor.com/extracting-attachments-from-outlook-using-c-sharp
Jun 25, 2020 03:38 PM|jzero|LINK
I think your best choice is ti use Mailkit/Mimekit to work with mails, you can get it on Nuget.
For how to check and extract attachments
Jun 26, 2020 02:37 AM|samwu|LINK
Hi Rakib Ahmed,
i mean my goal is to first to read email attachment from outlook email and then read attachment file like txt file and save that txt file information.
Here a demo about how to save e-mail attachments to a specified folder when the mail is received in the inbox.
This example works only if you add a folder named TestFileSave at the root of the C directory.
private void ThisAddIn_Startup(object sender, System.EventArgs e)
this.Application.NewMail += new Microsoft.Office.Interop.Outlook
private void ThisApplication_NewMail()
Outlook.MAPIFolder inBox = this.Application.ActiveExplorer()
Outlook.Items inBoxItems = inBox.Items;
Outlook.MailItem newEmail = null;
inBoxItems = inBoxItems.Restrict("[Unread] = true");
foreach (object collectionItem in inBoxItems)
newEmail = collectionItem as Outlook.MailItem;
if (newEmail != null)
if (newEmail.Attachments.Count > 0)
for (int i = 1; i <= newEmail
catch (Exception ex)
string errorInfo = (string)ex.Message
if (errorInfo == "Cannot save")
MessageBox.Show(@"Create Folder C:\TestFileSave");
More information about how to save attachments from Outlook email items you can refer to this link: