Question How do I create an Outlook?

Deemar

Member
Joined
Aug 19, 2008
Messages
8
Programming Experience
Beginner
I've got an application that's using MAPI right now but it's not reliable because my virus scanner (Trend Micro) blocks access and I can't have that happening after rolling it out to a client. So I'm wondering how I go about creating/displaying an email with Outlook via my application.

All I really need to do is create and display it on screen, the user can manually hit SEND in the email window when they want to. No automated sending required.
 

I liked your link to learning HTML in that first one!
So I checked the link and it seems to suggest the same things I've found on Google. I guess that may lead me into the root of my problem, I add the Microsoft Office 11.0 Object Library reference to my project but still cannot create Outlook items like in the example. For some reason I type outlook. and no suggestions come up, it doesn't recognize the outlook class. I have no idea why.

EDIT - it appears I've got a different version of VSTO installed, causing me to use a different Primary Interop Assembly (PIA) and all I get is the microsoft.office.core namespace. Am I still able to create emails with Outlook via VB.NET?
 
Last edited:
Not sure if the namespaces changed, you can use this named import and should be able to use same code (including most old office automation samples out there) :
VB.NET:
Imports Outlook = Microsoft.Office.Interop.Outlook
 
Not sure if the namespaces changed, you can use this named import and should be able to use same code (including most old office automation samples out there) :
VB.NET:
Imports Outlook = Microsoft.Office.Interop.Outlook

Doesn't work, Visual Studio can't find that package to import. The problem (as I can see from Google searches) is that I'm using an alternate version of the VSTO and therefore have to use the applicable version of the PIA, limiting me to the microsoft.office.core namespace. Does this sound right? I don't totally know what I'm talking about, all I simply want to do is display an email in Outlook.
 
I'm not familiar with VSTO, the "Microsoft Outlook 11.0 Object Library" or similar reference is all that should be required to start using that library.
 
Well it turns out that the VSTO installer was not placing the .dll files in the correct places and that's why it wasn't working when I installed it. Once I manually extracted the .exe and placed the .dll into the correct folder, I was able to access them as referenced files under the .NET tab of the References screen in my project. Finally.....thanks JohnH.

Now though we've decided to go another route, we're instead going to use the system.net.mail protocol because it'll work with Lotus Notes (or any STMP server) that our clients use. How do you get around the FROM address specification with this namespace? Can you specify it in the code at runtime? Can it be a system setting in the application? The email that gets sent out has to be from whoever is using the machine so is there a way to pull the current user's email address from their Outlook/Lotus/Open Office?
 
Deemar said:
How do you get around the FROM address specification with this namespace?
Not sure what you mean by namespace in here, but the From property of MailMessage class is set to an instance of MailAddress class, where you with several options provide the address as a string. This string can be saved in an application setting (good choice) or anywhere.

"Pulling" anything out of other applications is usually difficult, especially when it comes to high security data like personal account details. With Outlook it may be possible with automation, but if it is you would most likely encounter a user security dialog to permit access to this personal information. The easiest option is doing the same as any other email application; provide a dialog where user can input their account details.
 
Looks like we've changed directions with this module again. A lot of our clients use things other than Outlook so we're going to switch over to using the system.net.mail methods instead. We still need to display the email to the user prior to sending so I'm building a custom form to look kind of like an Outlook email form with a send button at the bottom. When they click send it'll just call the mail.send() method (or whatever it is) and send with all the relative information.

I appreciate all your help so far and if I post another reply, please take another look as I may have more problems as I progress!
 
Back
Top