Emailing using code


Stephen sjw_ost

I am using code to email my worksheet. Everytime I run the code I get a
message that says;
A program is trying to send an email on your behalf. Do you wish to continue?

Of course I want to continue because I am sending the email intentionally.
How can I stop this message from coming up and just have my Outlook email
Is this an Outlook security setting or can I bypass this message using VBA?

Thanks for any help


Here is the basic code:

Sub SendMyMail()

Dim msgTo As String

Set appOutlook = CreateObject("Outlook.Application")
Set MailOutLook = appOutlook.CreateItem(olMailItem)

msgTo = InputBox("Please enter e-mail address", "Address")

With MailOutLook
.To = msgTo
.CC = ""
.BCC = ""
.Subject = ""
.Body = Location
'.Attachments.Add "C:\Path\"
End With

MsgBox "Message sent to " & msgTo, vbOKOnly

End Sub

If you want to add an attachement, un-comment the .Attachements.Add line and
add the proper path.

Post back with questions!

Stephen sjw_ost

Yes, I have this code and am using it.
My question is, how do I stop the message from coming up that says;
A program is attempting to send an email on your behalf. Do you wish to

How do I stop this message from coming up and just seamlessly send the email
when the code is invoked?


Odd. The reason I use that code is because it stops the pop-up from coming
up. I see that someone posted a link. My network must have that

Please rate this post using the vote buttons if it was helpful.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question