Click here to Skip to main content
15,848,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is it possible to save an outlook msg file to a folder e.g. c:\temp

Dim Smtp_Client As New SmtpClient
Dim eMail As New MailMessage()

Can send an email Smtp_Client .Send(eMail) but there is nothing to SaveAs email

I know you can do it via Microsoft.Office.Interop.Outlook.Application but need to do as SmtpClient.

Help please

What I have tried:

Do see any VB code examples on the internet
Updated 23-Jan-18 5:21am
F-ES Sitecore 23-Jan-18 10:31am    
SMTP client communicates using the SMTP protocol which is a standard. msg is a proprietary format for Outlook which is a desktop application. MSG files rely on embedded documents and you can generally only create them using the Outlook API, MAPI, or using low-level COM techniques that .net doesn't support. You'll need to look for someone who has written some kind of .net wrapper that creates MSG files. There is a reader on this site somewhere so there might be a writer out there too.

I'd ask if you are trying to solve the right problem though, there might me another solution to what you're doing. If you want items you send via SmtpClient to appear in someone's "Sent Items" then you're using the wrong technology entirely.

1 solution

Something like this should work:
Dim Smtp_Client As New SmtpClient
Smtp_Client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory
Smtp_Client.PickupDirectoryLocation = "C:\temp\"

Dim eMail As New MailMessage

The message will be saved in the specified directory as an .eml file, which you can open with Outlook.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900