| Author |  | 
      
        | softwareguy Newbie
 
  
 
 Joined: 17 July 2010
 Location: United States
 Online Status: Offline
 Posts: 22
 | 
          This is a follow up to a previous post that indicated there may be some issue with opening a message extracted from a PST and saved to disk using the MailBee.NET library.
           | Posted: 21 July 2010 at 8:31pm | IP Logged |   |  
           | 
 |  
 Here is the code I'm using
 
 Private Sub SaveMessage()
 Dim fileName As String = "c:\test.msg"
 Dim itemCount As Integer
 Dim reader As PstReader = New PstReader("c:\test.pst")
 Dim folders As PstFolderCollection = reader.GetPstRootFolders(True)
 For Each folder As PstFolder In folders
 If folder.ShortName = "Inbox" Then
 itemCount = folder.Items.Count
 IO.File.Delete(fileName)
 Dim item As PstMessage = folder.Items(0)
 Dim msg As MailMessage = item.GetAsMailMessage
 msg.SaveMessage(fileName)
 Exit For
 End If
 Next
 End Sub
 
 Is there anything wrong with the above code?  It creates the msg file successfully, but when trying to open it in Outlook 2010, it gives the following error:
 
 "Cannot start Microsoft Outlook. Cannot open file: C:\test.msg.  The file may not exist, you may not have permission to open it, or it may be open in another program. Right-click the folder that contains the file, and then click Properties to check your permissions for the folder."
 
 Well, I have permission to the folder because I'm able to create/open/delete other files in that same folder.  Using a competing product I can extract and save the very same message file to that same folder and open it successfully in Outlook.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6167
 | 
          The code itself looks good, but it creates EML (RFC822) file, not Outlook MSG. Even though the extension is .msg, it's still .eml in fact. If you need to create MSG file, you might want to use this method instead of SaveMessage call.
           | Posted: 22 July 2010 at 1:03am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | softwareguy Newbie
 
  
 
 Joined: 17 July 2010
 Location: United States
 Online Status: Offline
 Posts: 22
 | 
          Well then, that just might explain the problem I'm having!  I'll give it a shot tonight.  Thanks!
           | Posted: 22 July 2010 at 7:57am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  |