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
Solved

Outlook Express Automation

Posted on 2001-08-04
6
1,017 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 101
Need to Obtain or Remove Password Protection From an Excel 2000 Workbook 6 71
Problem to line 23 54
Set WorkSheet  not Working 9 41
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
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.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
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…

837 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