send in outlook

0 votes
asked Jan 17, 2014 by ajhvdb (160 points)
edited Jan 20, 2014

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

Applies to: Rebex Secure Mail

2 Answers

0 votes
answered Jan 20, 2014 by Lukas Pokorny (123,550 points)
edited Jan 20, 2014

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
answered Jan 20, 2014 by ajhvdb (160 points)
edited Jan 20, 2014

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.

commented Jan 20, 2014 by Lukas Pokorny (123,550 points)
edited Jan 20, 2014

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

commented Jan 20, 2014 by Lukas Pokorny (123,550 points)
edited Jan 20, 2014

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.

commented Jan 20, 2014 by ajhvdb (160 points)
edited Jan 20, 2014

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.

commented Jan 20, 2014 by Lukas Pokorny (123,550 points)
edited Jan 20, 2014

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).

commented Jan 20, 2014 by ajhvdb (160 points)
edited Jan 20, 2014

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.

commented Jan 20, 2014 by Lukas Pokorny (123,550 points)
edited Jan 20, 2014

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.

...