Solved

Outlook Express Automation

Posted on 2001-08-04
6
1,028 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This collection of functions covers all the normal rounding methods of just about any numeric value.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

696 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