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
413 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Find out what you should include to make the best professional email signature for your organization.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

809 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