|
-
Jul 28th, 2010, 05:33 AM
#1
Thread Starter
Junior Member
Outlook add in: Saving email as MSG gives error "Object reference not set..."
Hi
I am trying to create a new email in Outlook 2007, and save it to local disc in vb.net.
It creates the new file, saves it, and I can open it from local disc(by double clicking on file) while outlook is still open.
But when I close outlook, and then try to open the file from disc, it does show the email message, but WITH an error messagebox saying : "Object reference not set to an instance of an object."
Anyone have an idea what could be wrong?
Code:
Imports Microsoft.Office.Interop.Outlook
Public Class save_message
Private Sub btn_send_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_send.Click
Dim oApp As Outlook.Application
Dim oMsg As Outlook.MailItem
oApp = New Outlook.Application()
oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
With oMsg
.To = "[email protected]"
.Subject = "this is the subject"
.Body = "this is the body"
End With
oMsg.SaveAs("c:\temp.msg", OlSaveAsType.olMSG)
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|