R
R Avery
I have been receiving an error message "Could not resolve the message
recipients" when using the following VBA code, but only when I include a
list of ReplyRecipients (even if I provide email addresses rather than
names for ReplyRecipients). However, before I wrote this using Outlook
Redemption, it worked just fine other than the fact that the security
dialog box always popped up. It could always resolve the recipients in
the past... what am I doing wrong?
Any help would be most appreciated.
Public Sub SendEmail(Optional ByVal ToWhom As String = "", Optional
ByVal Subject As String = "", _
Optional ByVal BodyText As String = "", Optional ByVal Attachments As
String = "", _
Optional ByVal ReplyRecipients As Variant, Optional ByVal AutoSend As
Boolean = False)
Dim myOlApp As Outlook.Application
Dim myitem As Outlook.MailItem
Dim safeMail
Set myOlApp = CreateObject("Outlook.Application")
Set myitem = myOlApp.CreateItem(olMailItem)
myitem.Body = BodyText
myitem.Subject = Subject
myitem.To = ToWhom
Set safeMail = CreateObject("Redemption.SafeMailItem")
safeMail.Item = myitem
If Not IsMissing(ReplyRecipients) Then
Dim i As Long
For i = LBound(ReplyRecipients) To UBound(ReplyRecipients)
safeMail.ReplyRecipients.Add ReplyRecipients(i)
Next i
End If
' I tried adding this code to fix the problem, but it did not work.
'safeMail.Recipients.Add ToWhom
'safeMail.Recipients.ResolveAll
'safeMail.ReplyRecipients.ResolveAll
If AutoSend Then
safeMail.Send
Else
safeMail.Save
End If
Set safeMail = Nothing
Set myitem = Nothing
Set myOlApp = Nothing
End Sub
recipients" when using the following VBA code, but only when I include a
list of ReplyRecipients (even if I provide email addresses rather than
names for ReplyRecipients). However, before I wrote this using Outlook
Redemption, it worked just fine other than the fact that the security
dialog box always popped up. It could always resolve the recipients in
the past... what am I doing wrong?
Any help would be most appreciated.
Public Sub SendEmail(Optional ByVal ToWhom As String = "", Optional
ByVal Subject As String = "", _
Optional ByVal BodyText As String = "", Optional ByVal Attachments As
String = "", _
Optional ByVal ReplyRecipients As Variant, Optional ByVal AutoSend As
Boolean = False)
Dim myOlApp As Outlook.Application
Dim myitem As Outlook.MailItem
Dim safeMail
Set myOlApp = CreateObject("Outlook.Application")
Set myitem = myOlApp.CreateItem(olMailItem)
myitem.Body = BodyText
myitem.Subject = Subject
myitem.To = ToWhom
Set safeMail = CreateObject("Redemption.SafeMailItem")
safeMail.Item = myitem
If Not IsMissing(ReplyRecipients) Then
Dim i As Long
For i = LBound(ReplyRecipients) To UBound(ReplyRecipients)
safeMail.ReplyRecipients.Add ReplyRecipients(i)
Next i
End If
' I tried adding this code to fix the problem, but it did not work.
'safeMail.Recipients.Add ToWhom
'safeMail.Recipients.ResolveAll
'safeMail.ReplyRecipients.ResolveAll
If AutoSend Then
safeMail.Send
Else
safeMail.Save
End If
Set safeMail = Nothing
Set myitem = Nothing
Set myOlApp = Nothing
End Sub