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
411 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
Comment Utility
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
Comment Utility
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
Comment Utility
JUst ignore me, morning David!

Chris
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 76

Expert Comment

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

Author Closing Comment

by:LearningToProgram
Comment Utility
thanks! that worked perfectly!
0
 
LVL 76

Expert Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Granting full access permission allows users to access mailboxes present in their database. By giving full access permission one can open and read the content of any mailbox but cannot send emails from that mailbox.
Outlook Free & Paid Tools
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 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

15 Experts available now in Live!

Get 1:1 Help Now