Outlook code To names need to detect even if after the first TO can be in any range in TO.
The below code does not work when i reply to a mail even when i reply and a user is in the TO or CC i want the others to be added into CC.
Say Frank sends a mail to me and i add Jerald into CC or To. When sent i want 2 more names to be added in CC because Jerald is there in To or CC.
the below code is from Chris
Sub toMe(mai As mailitem)
'Const Your_email_Addy As String = "smith, fred" ' DISPLAYED NAME!
Dim olkRecip As Object
Dim special As Variant
Dim index1 As Integer
Dim index2 As Integer
Dim sendto As String
Dim addr As Variant
Const special1 As String = "lookforaddress, email@example.com, firstname.lastname@example.org"
Const special2 As String = ""
Const special3 As String = ""
Const special4 As String = ""
Const special5 As String = ""
Const special6 As String = ""
special = Array(Split(special1, ", "), _
Split(special2, ", "), _
Split(special3, ", "), _
Split(special4, ", "), _
Split(special5, ", "), _
Split(special6, ", "))
For index1 = 0 To 5
sendto = ""
If UBound(special(index1)) < 1 Then Exit For
For index2 = 1 To 6
If UBound(special(index1)) >= index2 Then
If sendto <> "" Then sendto = sendto & ", "
If special(index1)(index2) <> "" Then sendto = sendto & special(index1)(index2)
debug.print LCase(mai.Recipients(1).Name) & " = " & LCase(special(index1)(0)) & "? .... " & LCase(mai.Recipients(1).Name) = LCase(special(index1)(0))
If LCase(mai.Recipients(1).Name) = LCase(special(index1)(0)) Then
If MsgBox("Append the common CC names" & vbCrLf & vbCrLf & sendto & "?", vbYesNo, "Append common recipients") = vbYes Then
For Each addr In Split(sendto, ", ")
Set olkRecip = mai.Recipients.Add(addr)
olkRecip.Type = olCC