Solved

Outlook Express Automation

Posted on 2001-08-04
6
1,004 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Leon
Software Metering within our group of companies has always been an afterthought until auditing of software and licensing became a pain point. Orchestrator and SCCM metering gave us the answer and it was an exciting process.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

743 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

11 Experts available now in Live!

Get 1:1 Help Now