|
-
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
-
Jul 28th, 2010, 12:21 PM
#2
Re: Outlook add in: Saving email as MSG gives error "Object reference not set..."
If you are creating an Outlook add in then this thread really belongs in the Office Development forum... but anyway - the code you have shown us is for saving the email but you say you get an error when loading the email so show us the code you are using for that.
-
Jul 29th, 2010, 02:42 AM
#3
Thread Starter
Junior Member
Re: Outlook add in: Saving email as MSG gives error "Object reference not set..."
Hi Chris
Thanks for you quick response.
Sorry i did not know there is a outlook section, I created another more detailed thread there:
http://www.vbforums.com/showthread.p...13#post3853913
Basically my code saves the message to c:\temp.msg
But when i try to manually open the file by (double clicking on it in explorer), it gives an error.
If someone can delete this thread they are welcome.
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
|