[AccessD] [Spam]8.51 Re: Get sender's eMail address

William Benson (VBACreations.Com) vbacreations at gmail.com
Wed Aug 31 13:44:41 CDT 2011


I could not get the code to run for me either just now. I have not tested it
since I went off the server at my major client. I thought all you would need
is a reference to Outlook, but apparently in order to use CDO one must have
a reference to that as well as be using Microsoft Exchange - so that
CreateObject("Mapi.Session") will work. Please accept my apologies for
wasting your time.

I may find another solution (other than using Redemption, which is
commercial - written by Dmitry
http://www.dimastr.com/redemption/download.htm ), which I also have
installed.

Bill Benson

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Darrell Burns
Sent: Wednesday, August 31, 2011 1:45 PM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] [Spam]8.51 Re: Get sender's eMail address

Sorry, I don't follow you. I'm referring to this code snippet...

    Dim Exp As Explorer, Itm As Object
    Set Exp = ActiveExplorer
    On Error Resume Next
    For Each Itm In Exp.Selection
        Debug.Print GetFromAddress(Itm)
    Next

I get a compile error on the Dim Exp as Explorer.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William Benson
Sent: Tuesday, August 30, 2011 7:04 PM
To: Access Developers discussion and problem solving
Subject: [Spam]8.51 Re: [AccessD] Get sender's eMail address

Outlook
Sorry

Dim olApp as outlook.Application
Set olapp = new outlook.application
 On Aug 30, 2011 9:41 PM, "Darrell Burns" <dhb at flsi.com> wrote:
> Hey Bill, what is the ActiveExplorer? What reference do I need to set?
>
> -----Original Message-----
> From: accessd-bounces at databaseadvisors.com
> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of William 
> Benson
> (VBACreations.Com)
> Sent: Tuesday, August 30, 2011 3:15 PM
> To: 'Access Developers discussion and problem solving'
> Subject: Re: [AccessD] Get sender's eMail address
>
> Make sure to set a reference to Outlook
>
> Sub test()
> Dim Exp As Explorer, Itm As Object
> Set Exp = ActiveExplorer
> On Error Resume Next
> For Each Itm In Exp.Selection
> Debug.Print GetFromAddress(Itm)
> Next
> End Sub
>
> Function GetFromAddress(objMsg)
> ' start CDO session
> Dim objSession As Object
> Dim strAddress As String
> Dim strEntryID As String
> Dim strStoreID As String
> Dim objCDOMsg As Object
>
> Set objSession = CreateObject("MAPI.Session") objSession.Logon "", "", 
> False, False
>
> ' pass message to CDO
> strEntryID = objMsg.EntryID
> strStoreID = objMsg.Parent.StoreID
> Set objCDOMsg = objSession.GetMessage(strEntryID, strStoreID)
>
> ' get sender address
> On Error Resume Next
> strAddress = objCDOMsg.Sender.Address
> If Err = &H80070005 Then
> 'handle possible security patch error
> MsgBox "The Outlook E-mail and CDO Security Patches are " & _ 
> "apparently installed on this machine. " & _ "You must response Yes to 
> the prompt about " & _ "accessing e-mail addresses if you want to " & 
> _ "get the From address.", vbExclamation, _ "GetFromAddress"
> End If
>
> GetFromAddress = strAddress
>
> Set objCDOMsg = Nothing
> objSession.Logoff
> Set objSession = Nothing
> End Function
> On 30 Aug 2011 at 14:11, Darrell Burns wrote:
>
>> Does anybody have any VBA code for getting the sender's email address?
>> I need this as the "from" argument for a mailitem object used in an 
>> SMTP call. Thanx, Darrell
>>
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> http://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list