0 votes
by (160 points)
edited

I have seen a lot of examples to create outlook messages like:

Dim RebexMessage As New MailMessage
RebexMessage.Subject = "Subject"
RebexMessage.BodyHtml = "Body"
RebexMessage.Save("D:\rebexmail.msg", MailFormat.OutlookMsg)

But what i would like to know how to open and send this in outlook? open and save in outlook would be ok too?

Do you have an example or a link?

Thx

2 Answers

0 votes
by (148k points)
edited

To open a .msg file in Outlook, simply browse to the drive and folder where it's stored (D:\ in this case) and double-click the .msg file.

Alernatively, you can drag&drop the .msg file into a folder in Outlook.

For some strange reason, Outlook's File->Open menu lacks the ability to open .msg files, but the two methods above should work fine.

Update: To open the .msg file i Outlook programatically, try this:

System.Diagnostics.Process.Start("D:\rebexmail.msg")

This is equivalent to double-clicking the file in Windows Explorer (which means it opens the file with an associated application, which for .MSG files happens to be Outlook)

0 votes
by (160 points)
edited

Thank you for your answer. For a user double clicking is clear but what I would like to know is "how to do this from code?"

Google is not my friend in this :) as I can't find a good example and to know which interop file I need for office xp or office 2010.

by (148k points)
edited

For opening the file, you don't even need any Office interop file - I updated my answer above.

by (148k points)
edited

I'm afraid you would need it if you wanted to programatically send the messages using Outlook as well. Check out http://msdn.microsoft.com/en-us/library/office/ff869601.aspx and http://msdn.microsoft.com/en-us/library/15s06t57.aspx , but this is outside the scope of Rebex support, unfortunately.

by (160 points)
edited

The second link is not working. Sorry.

I want to open the msg file in the running version of the user's outlook. Then do some extra actions to the email to make it useable for sending.

by (148k points)
edited

Just fixed the link, sorry! System.Diagnostics.Process.Start should actually open the file in the running version of user's Outlook (or launch a new instance if not running).

by (160 points)
edited

Thanks, didn't notice the comma :)

If I use the process.start then after this I can't do extra actions with the email.. because I don't have any reference to it.

by (148k points)
edited

I know :-(

If you can't do those extra actions with the email before calling Process.Start, then Outlook Interop would indeed be your only option, as far as I know.

...