INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VBA Visual Basic for Applications (Microsoft) FAQ

VBA How To

Send an Email In Excel without Prompts by robcarr
Posted: 22 Oct 03

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 'defines attachment
dname = [b14].value 'defines date for subject
Dim objol As New outlook.Application
Dim objmail As MailItem
Set objol = New outlook.Application
Set objmail = objol.createitem(olmailitem)
    With objmail
        .To = "whoever" 'enter in here the email address
        .cc = "whoever" 'enter in here the email address
        .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 'adds attachment to email
        .display
    End With
    Set objmail = Nothing
    Set objol = Nothing
    SendKeys "%{s}", True 'send the email without prompts
    
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.

Back to VBA Visual Basic for Applications (Microsoft) FAQ Index
Back to VBA Visual Basic for Applications (Microsoft) Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close