Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 2000 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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
This article describes how to import Lotus Notes Contacts into Outlook 2016, 2013, 2010 and 2007 etc. with a few manual steps. You can easily export and migrate Lotus Notes contacts into Microsoft Outlook without having to use any third party tools.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

618 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