Solved

From Access: How to determine the email address of the CC's in an incoming email in Outllok

Posted on 2011-02-10
6
412 Views
Last Modified: 2012-05-11
Hi,
I am using Access VBA to import incoming emails from an Outlook 2000 inbox into an Access 2007 database.
I have used redemption to determine the email address of the sender, and this is working fine.
Now I need to determine the email address of any cc's (recipients who were carbon copied on the email).
Can someone help me out with the code needed to do this?
I'm not sure if I need to use Redemption for this like I do for the sender's email address or if I can do it using Outlook. (I can't use CDO)
I've attached the code using Redemption to get the sender's email, but I don't understand how to alter this to get the cc's.
thanks.
Paul

Function R_GetSenderAddress(objMsg)
  Dim strType
  Dim objSenderAE ' Redemption.AddressEntry
  Dim objSMail    ' Redemption.SafeMailItem
  Const PR_SENDER_ADDRTYPE = &HC1E001E
  Const PR_EMAIL = &H39FE001E

  Set objSMail = CreateObject("Redemption.SafeMailItem")
  objSMail.Item = objMsg
  strType = objSMail.Fields(PR_SENDER_ADDRTYPE)
  Set objSenderAE = objSMail.Sender
  If Not objSenderAE Is Nothing Then
    If strType = "SMTP" Then
      R_GetSenderAddress = objSenderAE.Address
    ElseIf strType = "EX" Then
      R_GetSenderAddress = objSenderAE.Fields(PR_EMAIL)
    End If
   End If

   Set objSenderAE = Nothing
   Set objSMail = Nothing
End Function

Open in new window

0
Comment
Question by:LearningToProgram
  • 3
  • 2
6 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 34870045
Hi, Paul.

Something like this should get the job done.  I'm not in a position to test this right now as I don't have a computer available that has Redemption loaded.
Function R_GetCCAddresses(objMsg As Outlook.MailItem) As String
    Dim objSMail    ' Redemption.SafeMailItem
    Dim objRecip
    Set objSMail = CreateObject("Redemption.SafeMailItem")
    objSMail.Item = objMsg
    For Each objRecip In objSMail.Recipients
        If objRecip.Type = olCC Then
            R_GetCCAddresses = R_GetCCAddresses & objRecip.Address & ","
        End If
    Next
    If Len(R_GetCCAddresses) > 0 Then
        R_GetCCAddresses = Mid(R_GetCCAddresses, 1, Len(R_GetCCAddresses) - 1)
    End If
    Set objRecip = Nothing
    Set objSMail = Nothing
End Function

Open in new window

0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34870072
I would think you can use objSMail to get them along the lines of:

for each recip in objSMail.recipients
    debug.print recip.address
next

YOu will need to consider each as SMTP or exchange as for the from but in terms of getting the root data it should be that easy.

Chris
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 34870088
JUst ignore me, morning David!

Chris
0
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 76

Expert Comment

by:David Lee
ID: 34871285
Good morning, Chris!  Well, probably more like afternoon for you.
0
 

Author Closing Comment

by:LearningToProgram
ID: 34889905
thanks! that worked perfectly!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 34890094
You're welcome.  Happy I could be of service.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Read this checklist to learn more about the 15 things you should never include in an email signature.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

895 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

14 Experts available now in Live!

Get 1:1 Help Now