S
Sunil Thomas
Hello All,
I am new to VB/VBA, so please bear with me.
I am running a loop to add E-mail addresses to a string sCCEMailAddr (which can have multiple e-mail addresses when the loop is completed all received from a table). It just sends a confirmation e-mail to specific email from an access table. But I get a Run-Time error 13 with Type Mismatch for this string. The code for outlook is listed below.
Dim OlkApp As Outlook.Application
Dim OlkMsg As Outlook.MailItem
Dim OlkToRecip As Outlook.Recipient
Dim OlkCCRecip As Outlook.Recipient
Dim OlkCCRecipM As Outlook.Recipients ' Multiple recipients
With OlkMsg
'MsgAddress the "To" address of message
Set OlkToRecip = .Recipients.Add(sToEMailAddr)
OlkToRecip.Type = olTo
'CC portion
If c = 1 Then
Set OlkCCRecip = .Recipients.Add(sCCEMailAddr)
OlkCCRecip.Type = olCC
Else
Set OlkCCRecipM = .Recipients.Add(sCCEMailAddr) <--------------Error comes up here when I click debug
OlkCCRecipM.Type = olCC
End If
'Subject
.Subject = "RM Confirmation # " & glID
.Body = sBody
'Save the finished message in Draft.
.Save
.close olPromtForSave
End With
This script works if I am sending to one person in the To and CC, but fails when I have multiple address in CC portion. I could not find any helpful solution thus far on the internet.
Any help would be greatly appreciated.
Thanks in advance
I am new to VB/VBA, so please bear with me.
I am running a loop to add E-mail addresses to a string sCCEMailAddr (which can have multiple e-mail addresses when the loop is completed all received from a table). It just sends a confirmation e-mail to specific email from an access table. But I get a Run-Time error 13 with Type Mismatch for this string. The code for outlook is listed below.
Dim OlkApp As Outlook.Application
Dim OlkMsg As Outlook.MailItem
Dim OlkToRecip As Outlook.Recipient
Dim OlkCCRecip As Outlook.Recipient
Dim OlkCCRecipM As Outlook.Recipients ' Multiple recipients
With OlkMsg
'MsgAddress the "To" address of message
Set OlkToRecip = .Recipients.Add(sToEMailAddr)
OlkToRecip.Type = olTo
'CC portion
If c = 1 Then
Set OlkCCRecip = .Recipients.Add(sCCEMailAddr)
OlkCCRecip.Type = olCC
Else
Set OlkCCRecipM = .Recipients.Add(sCCEMailAddr) <--------------Error comes up here when I click debug
OlkCCRecipM.Type = olCC
End If
'Subject
.Subject = "RM Confirmation # " & glID
.Body = sBody
'Save the finished message in Draft.
.Save
.close olPromtForSave
End With
This script works if I am sending to one person in the To and CC, but fails when I have multiple address in CC portion. I could not find any helpful solution thus far on the internet.
Any help would be greatly appreciated.
Thanks in advance