JBuckner wrote:
My macro uses the Send Object (VBA Item.Send) function to email a
spreadsheet to an Outlook contact list. I want the function to be completely
automatic but Outlook displays a security warning message (...another
program is attempting to automatically email...) that requires user
intervention before the macro will finish execution.
You may wish to use CDO. Here is a sample.
Public Sub VerySimpleSendMailWithCDOSample()
Dim iCfg As Object
Dim iMsg As Object
Set iCfg = CreateObject("CDO.Configuration")
Set iMsg = CreateObject("CDO.Message")
With iCfg.Fields
..Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"smtp.aim.com"
..Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")
= 1
..Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =
"MyUserName"
..Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
"MyPassord"
..Item("http://schemas.microsoft.com/cdo/configuration/sendemailaddress")
= "Lyle Fairfield <ly***********@aim.com>"
..Update
End With
With iMsg
..Configuration = iCfg
..Subject = "Temp.xls"
..To = "lf********@cogeco.ca"
..TextBody = "This is the latest!"
..AddAttachment "C:\Program Files\Backup Scripts\Temp.xls"
..Send
End With
Set iMsg = Nothing
Set iCfg = Nothing
End Sub
I believe that you can link to your Outlook Contacts (File - Get
External Data - Link Tables) to get your addresses.