From Access: How to determine the email address of the CC's in an incoming email in Outllok
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 = NothingEnd Function
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 = NothingEnd Function
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.
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.
Open in new window