Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Excel Email distribution

Status
Not open for further replies.

conte

Technical User
Jul 10, 2003
8
US
I have to following codes to automate email distribution. Tne email list is an excel file. But everytime a new email is created and to be sent, a screen saying "A program is trying to send email automatically on your behalf. Do you want to allow this?"pops up. But when you are sending 500 emails, you do not want to click "yes" every time. Can some help me to include a code in the body to eliminate this screen or select "yes" automatically?

Dim sht As Worksheet
Dim FirstRow As Integer
Dim LastRow As Integer
Dim SendTo As String, Esubject As String, Ebody As String
Dim MonOutlook As Object
Dim MonMessage As Object
Set sht = Worksheets("Sheet1")

FirstRow = 2
LastRow = 4
For x = 2 To 4
Set MonOutlook = CreateObject("Outlook.Application")
Set MonMessage = MonOutlook.createitem(0)
Ebody = sht.Range("F" & x).Value
Esubject = sht.Range("E" & x).Value
SendTo = sht.Range("D" & x).Value
NewFileName = sht.Range("G" & x).Value
MonMessage.To = SendTo
MonMessage.Subject = Esubject
MonMessage.body = Ebody
MonMessage.Attachments.Add (NewFileName)
MonMessage.send
Set MonOutlook = Nothing
Set MonMessage = Nothing
Next x
End Sub
 
The only difference between your coding and mine is the these lines

Dim objol As New outlook.Application
Dim objmail As MailItem
Set objol = New outlook.Application
Set objmail = objol.createitem(olmailitem)

I specify outlook as a new item and I don't get the Outlook security prompt, I am using the email coding in Excel and on a Win NT with outlook 2000.

Hope it helps.

Thanks Rob.[yoda]
 

Newboy

I tried your link and it works quite well. Thanks for helping.

Conte

 
Rob,

I tried to include your codes into mine but somehow, I could not have it working, I think that may be because I have excel and outlook 2002. I have the following message "outlook.application could not be found".

Thanks for helping.

Conte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top