Home > Enterprise >  Select based on email CC
Select based on email CC

Time:08-07

Hi I would like to archive inbox emails based on cc list and to list. I have come across the Mailitem.CC property and Mailitem.SenderEmailAddress. What kind of output are these? Will it return a list? If I want to select all emails with the same domain, what would the code be like? Thanks.

CodePudding user response:

To / CC / BCC properties return a ";" separated list of names (which can be addresses) - see https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.cc

If you need the addresses, loop through all recipients (Recipient object) in the MailItem.Recipients collection and read the Recipient.Address property. You can also check the value of the Recipient.Type property (olTo / olCC / olBCC).

If you are not sure what a particular property represents, you can see Outlook Object Model objects live in OutlookSpy (I am its author - click Item button to see the properties, methods, and events of the currently selected item).

CodePudding user response:

What kind of output are these? Will it return a list? If I want to select all emails with the same domain, what would the code be like?

There are all string properties that contain separated by ; list of names or email addresses.

If you need to get items with the same domain name you need to use the Find/FindNext or Restrict methods of the Items class. These methods are described in depth in my articles:

For example, a possible search criteria can be used to get items from the domain.info domain (VBA syntax):

criteria = "@SQL=" & Chr(34) _ 
& "urn:schemas:httpmail:senderemail" & Chr(34) _ 
& " like '%domain.info%'" 

Read more about string based search in the Filtering Items Using a String Comparison article.

  • Related