View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default VBA to Email Attachment

Ron de Bruin has an approach that uses CDO rather than you mail software.
See his discussion at his site:

Ron de Bruin's site

http://www.rondebruin.nl/sendmail.htm
http://www.rondebruin.nl/index.html

an Article by Ron on MSDN:
http://msdn.microsoft.com/library/en...odc_xlmail.asp

The index should lead you there. The article is for interest although not
particularly directly appropriate.

--
Regards,
Tom Ogilvy

"Jim Palmer " wrote in message
...
I have a macro that emails monthly reports to several department heads.

Does anyone know if there is a way to prevent the message "A program is
tyring to automatically send email on your behalf ... if this is
unexpected it could be a virus" ?

I have to press "yes" each time, and the macro sends reports to many
addresses.

I understand the need for this security, however I would think there is
some way to advise the computer "it's okay, it's me".

Any assistance would be appreciated.

The code I use follows:

Sub SendReports()


Dim ol As Object, myItem As Object
Set ol = CreateObject("outlook.application")


MyText = Range("Email_Comment").Value



Set myItem = ol.CreateItem(olMailItem)
myItem.To = "email address"
myItem.Subject = "Subject Line"
myItem.Body = MyText
myItem.Body = myItem.Body & "" & Chr(13) & Chr(13)

Set myAttachments = myItem.Attachments
myAttachments.Add "Path name of file to attach"
myItem.Send


' Other addresses and attachments are entered here

Set ol = Nothing


End Sub


---
Message posted from http://www.ExcelForum.com/