I am using redemption code vba to send emails in my excel application (apparently a safer way to email using vba)
The code is intended for users and therefore the emails would be sent by the code instead of the user (to avoid any tampering, etc by the user with sensitive information in the email)
The main issue I am having is getting the excel vba code to resolve email names/groups without having the Outlook security warning pop up, as well as the issue of having the email get sent before the names/groups are resolved (which causes Error Number: -2147418113: "Could not resolve the message recipients" - even though the address is legitimate).
I have simplified my code and hard coded my email variables for this example, using fake addresses instead of group names. I also replaced the .SEND command with the .DISPLAY command to view if the addresses have been resolved or not. In actuality the email addresses will be different group names that, if not resolved, would cause an error when sending with the .SEND command. (as noted in the previous paragraph)
However, If i change the "With SafeItem.Item" statement to "With SafeItem" only (removing the ".Item" at the end), the email does display but it does not seem to be resolving, hence no security pop up appears. ("SafeItem.Recipients.ResolveAll" does not seem to be doing anything actually.)
How can I resolve the addresses without getting the outlook warning?
The code is intended for users and therefore the emails would be sent by the code instead of the user (to avoid any tampering, etc by the user with sensitive information in the email)
The main issue I am having is getting the excel vba code to resolve email names/groups without having the Outlook security warning pop up, as well as the issue of having the email get sent before the names/groups are resolved (which causes Error Number: -2147418113: "Could not resolve the message recipients" - even though the address is legitimate).
I have simplified my code and hard coded my email variables for this example, using fake addresses instead of group names. I also replaced the .SEND command with the .DISPLAY command to view if the addresses have been resolved or not. In actuality the email addresses will be different group names that, if not resolved, would cause an error when sending with the .SEND command. (as noted in the previous paragraph)
Code:
Sub email()
Dim OL_App As Object
Dim OL_item As Object
Dim namespace
Dim SafeItem, oItem, ccRecip
Set OL_App = CreateObject("Outlook.Application")
Set ol_item = OL_App.CreateItem(0) 'Create a new message
Set namespace = OL_App.GetNamespace("MAPI")
namespace.Logon
Set SafeItem = CreateObject("Redemption.safeMailItem")
SafeItem.Item = ol_item 'set Item property
strTo = "[email="[email protected]"][email protected][/email]; [email="[email protected]"][email protected][/email]" 'these would actually be a group name
StrCC = "[email="[email protected]"][email protected][/email]; [email="[email protected]"][email protected][/email]" 'these would actually be a group name
strBody = "testing it out"
strSubject = "Will it do it?"
With SafeItem.Item
.Subject = strSubject
.To = strTo
.CC = StrCC
.Body = strBody
.Recipients.ResolveAll 'security msg pops up from this line!!!!
.Display
End With
Set OL_App = Nothing
Set SafeItem = Nothing
End Sub
How can I resolve the addresses without getting the outlook warning?