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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send an Email In Excel without Prompts

VBA How To

Send an Email In Excel without Prompts

by  robcarr  Posted    (Edited  )
Dear All,

Here is the coding to send an email in Excel without Outlooks Security prompt appearing asking if this is safe to send.

Sub Mailer()
Sheets("BB Email Data").Select
pathname = [b11].value [color red]'defines attachment[/color]
dname = [b14].value [color red]'defines date for subject[/color]
Dim objol As New outlook.Application
Dim objmail As MailItem
Set objol = New outlook.Application
Set objmail = objol.createitem(olmailitem)
With objmail
.To = "whoever" [color red]'enter in here the email address[/color]
.cc = "whoever" [color red]'enter in here the email address[/color]
.Subject = "Daily test email for " & dname
.Body = "Please find attached the teste email" & _
vbCrLf & "If you have any queries can you please let me know" & vbCrLf
.NoAging = True
.Attachments.Add pathname [color red]'adds attachment to email[/color]
.display
End With
Set objmail = Nothing
Set objol = Nothing
SendKeys "%{s}", True [color red]'send the email without prompts[/color]

End Sub



I have used this email coding in Excel for the last 6 months, on a WIN NT PC with outlook 2000, and also on Windows XP with Office XP, and do not get any security prompts at all, if you step through the coding it won't send, but if you run the coding normally, it will send an email with an attachment to anybody you like.

Hope this helps.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top