Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Outlook Express Automation

Posted on 2001-08-04
6
Medium Priority
?
1,059 Views
Last Modified: 2012-05-04
Is it possible to use outlook express through VB?( The way Outlook ( !Express) uses automation??)If so, how can it be done?
0
Comment
Question by:rasaraja
6 Comments
 
LVL 3

Accepted Solution

by:
cmgarnett earned 200 total points
ID: 6351132
I don't think its possible with automation, in the way that it is with Outlook.

Using the MAPI Session and MAPI Message controls on a form is pretty simple though.

This is some code that I have used successfully
   
   'Clear down any previous e-mail sessions
   frmMain.MapiMESSAGE.SessionID = 0
   
   'Start up an e-mail session
   frmMain.MAPISession.SignOn
   frmMain.MapiMESSAGE.SessionID = frmMain.MAPISession.SessionID
   
   'Compose a new email message
   frmMain.MapiMESSAGE.Compose
   frmMain.MapiMESSAGE.MsgIndex = -1
   
   'Set up the message address(es)
   frmMain.MapiMESSAGE.RecipIndex = 0
   frmMain.MapiMESSAGE.RecipDisplayName = strAddress
   frmMain.MapiMESSAGE.ResolveName
   
   'Set up the message
   frmMain.MapiMESSAGE.MsgSubject = gstrMessageSubject
   frmMain.MapiMESSAGE.MsgNoteText = fGetMessageText
     
   'Send the message
   frmMain.MapiMESSAGE.Send True
   DoEvents
   
   'Close down the e-mail session
   frmMain.MAPISession.SignOff
   frmMain.MapiMESSAGE.SessionID = 0

Hope it helps.
0
 
LVL 2

Expert Comment

by:adityau
ID: 6351155
Please check in your Project References, if Microsoft Outlook Express is listed. If it is listed, you can check it and use for automation.
0
 
LVL 15

Expert Comment

by:mohan_sekar
ID: 6351220
Hi,

      If u have Outlook express listed in your Project-References Menu then the following code will work

Public golApp As Outlook.Application
Public gnspNameSpace As Outlook.NameSpace

Function InitializeOutlook() As Boolean
   On Error GoTo Init_Err
   Set golApp = New Outlook.Application    ' Application object.
   Set gnspNameSpace = golApp.GetNamespace("MAPI") ' Namespace object.
   InitializeOutlook = True
Init_End:
   Exit Function
Init_Err:
   InitializeOutlook = False
   Resume Init_End
End Function

Function CreateMail(astrRecip As Variant, strSubject As String, strMessage As String, Optional astrAttachments As Variant) As Boolean
   Dim objNewMail As Outlook.MailItem
   Dim varRecip As Variant
   Dim varAttach As Variant
   Dim blnResolveSuccess As Boolean
   
   On Error GoTo CreateMail_Err
   If golApp Is Nothing Then
      If InitializeOutlook = False Then
         MsgBox "Unable to initialize Outlook Application " & "or NameSpace object variables!"
         Exit Function
      End If
   End If

   Set golApp = New Outlook.Application
   Set objNewMail = golApp.CreateItem(olMailItem)
   With objNewMail
      blnResolveSuccess = .Recipients.ResolveAll
      objNewMail.Display
      .To = astrRecip
      .Subject = strSubject
      .Body = strMessage
   End With
   CreateMail = True
CreateMail_End:
   Exit Function
CreateMail_Err:
   CreateMail = False
   Resume CreateMail_End
End Function

call the function using the following code

    CreateMail email1.Text, "Message", ""

bye
:-)

Mohan
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 14

Expert Comment

by:wsh2
ID: 6351320
<ping>.. Listening
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6352272
The presence of outlook express library depends of IE version, version 5 and above doesn't expose that.
0
 

Author Comment

by:rasaraja
ID: 6352651
Hi ,

cmgarnett u'r code was excellent.Thanks a lot.
Mohan u'r stuff is for Microsoft Outlook and not Outlook Express.
Bye.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question