Solved

Outlook Express Automation

Posted on 2001-08-04
6
1,010 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 50 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

861 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now