A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Create MAPI Session failure



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old April 23rd 08, 08:15 PM posted to microsoft.public.outlook.program_vba
derek mang
external usenet poster
 
Posts: 1
Default Create MAPI Session failure

I am using Windows XP pro with Office 2003. Within Outlook, I have a
series of macros to facilitate handling of specific emails.

Within this, one function is to extract the sender's email address using
CDO - which fails (Code below). I use the same .otm file on a different
machine wito Windows XP pro and Outlook 2002, and it's perfect.

CDO 1.21 is referenced.


Any thoughts would be appreciated
Regards
Derek

Option Explicit

Public G_objSession As MAPI.Session

Sub SetCDOSession()

' start CDO session
Set G_objSession = CreateObject("MAPI.Session")
G_objSession.Logon , , False, False

End Sub

Sub UnsetCDOSession()

' start CDO session
Set G_objSession = Nothing

End Sub

Function GetFromAddress(objMsg As MailItem) As String

Dim strEntryID As String
Dim strStoreID As String
Dim objCDOItem As MAPI.Message

' get EntryID and StoreID for message
strEntryID = objMsg.EntryID
strStoreID = objMsg.Parent.StoreID


If G_objSession Is Nothing Then
' Set the CDO Session up as it doesn't exist.
Call SetCDOSession
End If

' pass item to CDO and get sender address
On Error Resume Next
Set objCDOItem = G_objSession.GetMessage(strEntryID, strStoreID)

GetFromAddress = objCDOItem.Sender.Address

Set objCDOItem = Nothing

End Function



*** Sent via Developersdex http://www.developersdex.com ***
Ads
  #2  
Old April 23rd 08, 09:01 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Create MAPI Session failure

You can't run code in an OTM file in Outlook 2003 SP2 or higher I believe it
is. You can only run code from published forms.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"derek mang" wrote in message
...
I am using Windows XP pro with Office 2003. Within Outlook, I have a
series of macros to facilitate handling of specific emails.

Within this, one function is to extract the sender's email address using
CDO - which fails (Code below). I use the same .otm file on a different
machine wito Windows XP pro and Outlook 2002, and it's perfect.

CDO 1.21 is referenced.


Any thoughts would be appreciated
Regards
Derek

Option Explicit

Public G_objSession As MAPI.Session

Sub SetCDOSession()

' start CDO session
Set G_objSession = CreateObject("MAPI.Session")
G_objSession.Logon , , False, False

End Sub

Sub UnsetCDOSession()

' start CDO session
Set G_objSession = Nothing

End Sub

Function GetFromAddress(objMsg As MailItem) As String

Dim strEntryID As String
Dim strStoreID As String
Dim objCDOItem As MAPI.Message

' get EntryID and StoreID for message
strEntryID = objMsg.EntryID
strStoreID = objMsg.Parent.StoreID


If G_objSession Is Nothing Then
' Set the CDO Session up as it doesn't exist.
Call SetCDOSession
End If

' pass item to CDO and get sender address
On Error Resume Next
Set objCDOItem = G_objSession.GetMessage(strEntryID, strStoreID)

GetFromAddress = objCDOItem.Sender.Address

Set objCDOItem = Nothing

End Function



*** Sent via Developersdex http://www.developersdex.com ***


  #3  
Old April 23rd 08, 09:13 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Create MAPI Session failure

You're thinking of an .oft file, I think. .otm would be VBA. The most likely cause is that CDO 1.21 isn't installed on the problem machine.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ken Slovak - [MVP - Outlook]" wrote in message ...
You can't run code in an OTM file in Outlook 2003 SP2 or higher I believe it
is. You can only run code from published forms.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"derek mang" wrote in message
...
I am using Windows XP pro with Office 2003. Within Outlook, I have a
series of macros to facilitate handling of specific emails.

Within this, one function is to extract the sender's email address using
CDO - which fails (Code below). I use the same .otm file on a different
machine wito Windows XP pro and Outlook 2002, and it's perfect.

CDO 1.21 is referenced.


Any thoughts would be appreciated
Regards
Derek

Option Explicit

Public G_objSession As MAPI.Session

Sub SetCDOSession()

' start CDO session
Set G_objSession = CreateObject("MAPI.Session")
G_objSession.Logon , , False, False

End Sub

Sub UnsetCDOSession()

' start CDO session
Set G_objSession = Nothing

End Sub

Function GetFromAddress(objMsg As MailItem) As String

Dim strEntryID As String
Dim strStoreID As String
Dim objCDOItem As MAPI.Message

' get EntryID and StoreID for message
strEntryID = objMsg.EntryID
strStoreID = objMsg.Parent.StoreID


If G_objSession Is Nothing Then
' Set the CDO Session up as it doesn't exist.
Call SetCDOSession
End If

' pass item to CDO and get sender address
On Error Resume Next
Set objCDOItem = G_objSession.GetMessage(strEntryID, strStoreID)

GetFromAddress = objCDOItem.Sender.Address

Set objCDOItem = Nothing

End Function


  #4  
Old April 24th 08, 02:27 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Create MAPI Session failure

You're right of course, too many abbreviations to keep track of sound of
slapping upside head

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Sue Mosher [MVP-Outlook]" wrote in message
...
You're thinking of an .oft file, I think. .otm would be VBA. The most likely
cause is that CDO 1.21 isn't installed on the problem machine.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MAPI Session Logon error AVIS Outlook and VBA 17 April 29th 08 01:12 PM
CDO Outlook security prompt hangs, vb script Mapi Session [email protected] Outlook and VBA 2 April 17th 08 11:03 AM
OLK2007 : The Oper Failed : Application.CreateObject("MAPI.Session Bill Billmire Outlook - Using Forms 3 January 7th 07 01:02 AM
Error creating an MAPI session Dominique Schroeder Outlook - Using Forms 1 March 7th 06 02:25 PM
MAPI failure with Outlook\Exchange 2003 (MAPI_E_NOT_ME) charlied Outlook - General Queries 0 February 10th 06 06:20 PM


All times are GMT +1. The time now is 03:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.