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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.