Creating VBA button to send an email

T

Todd Huttenstine

I have an Excel Worksheet with a VBA button on it. I need
for when the user clicks the button, it to bring up a NEW
Email using Outlook 2000. I need for the subject to
say "URGENT Quick Notes Feeback" and for it to be address
to (e-mail address removed)"

Thanks in advance to all who reply.


Todd Huttenstine
 
B

Bob Phillips

Todd,

Put this code in your macro
Dim objOutlook As Object
Dim objMailItem As Object
Dim objRecipient As Object
Dim objNameSpace As Object

Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNameSpace("MAPI")
objNameSpace.Logon , , True

Set objMailItem = objOutlook.CreateItem(0)
Set objRecipient =
objMailItem.Recipients.Add("(e-mail address removed)")
objRecipient.Type = 1
objMailItem.Subject = "URGENT Quick Notes Feeback."
objMailItem.Send


If you want yhou macro to just bring up the Outlook mail rather than
automatically sending it, change the .Send at the end to .Display.
 
T

Todd Huttenstine

Is there anyway to have it not bring up that message
of "This program is trying to access an email address you
have stored in your Outlook address. Do you want to allow
this"? And when it brings it up, I have to click Yes 2
times. Its like it brings up 2 of those messages.

Thank you
 
B

Bob Phillips

Todd,

I don't get this message, though I do admit that I have had it at times when
some internet software has tried to send email out and my firewall has
trapped it. You could put DisplayAlerts = False at the start, but as I don't
think it is within VBA I think it will make no difference.

Do you have a firewall program? If so, I would suggest it is caused by that,
and you learn to live with it rather than degrade your protection.
 
T

Taliesin

I get this at home (XP) and one site that I work at (Windows 2000) but not
at the other (WinNT) so it's either part of the OS or part of later versions
of Outlook
 

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

Top