save Outlook 2007 email as a msg file from VB.NET 2008 - TechRepublic
Question
November 17, 2010 at 10:09 AM
bethfell

save Outlook 2007 email as a msg file from VB.NET 2008

by bethfell . Updated 15 years, 7 months ago

I want to save the selected Outlook 2007 email(s) as a msg file(s) from VB.NET (VS 2008). I get an error message that says ?You do not have the appropriate permissions to perform this operation.? I set the folder permissions for my profile, default and anonymous to full read, edit all for write and folder owner and folder visible for the other category. (just trying to cover all bases!)

Here?s my code and the error occurs on the save as statement. Thanks in advance for any insight!

Dim i As Int16
Dim temp As Object
Dim mailitem As Microsoft.Office.Interop.Outlook.MailItem
Dim subject As String
Dim strSaveName As String

For i = 1 To OL.ActiveExplorer().Selection.Count
temp = OL.ActiveExplorer().Selection(i)
Next
If (TypeOf (temp) Is Microsoft.Office.Interop.Outlook.MailItem) Then
mailitem = temp
subject = mailitem.Subject.Replace(“:”, “”)
subject = mailitem.Subject.Replace(“.”, “”)
strSaveName = subject & Format(Now, ” ddmmyyyyhhnnss”) & “.msg”
mailitem.SaveAs(strDir & strSaveName, Microsoft.Office.Interop.Outlook.OlSaveAsType.olMSG)

This discussion is locked

All Comments