Frank Freese
asked on
VBA for Outlook
Good morning folks,
This is a VBA Outlook need. In searching the Internet for Outlook VBA examples I haven't found an example of what I would like to do.
I send a lot of emails to myself so when I go to the To: selection or Copy: selection I have to type in my email address. Is it possible to have code that will allow me to click on To or Copy then using the short-cut menu click on an option to add my email address with having to type it in all the time? I would be interested to see what the code looks like. I use Outlook 2016 and have not even located a publication for VBA Outlook programming.
This is a VBA Outlook need. In searching the Internet for Outlook VBA examples I haven't found an example of what I would like to do.
I send a lot of emails to myself so when I go to the To: selection or Copy: selection I have to type in my email address. Is it possible to have code that will allow me to click on To or Copy then using the short-cut menu click on an option to add my email address with having to type it in all the time? I would be interested to see what the code looks like. I use Outlook 2016 and have not even located a publication for VBA Outlook programming.
ASKER
Thanks Bill. I will consider your suggestions, however, and it may not be possible with VBA for Outlook
Why not have a desktop shortcut with a key assignment which runs the following command:
You can then press the key combination you assign to the shortcut and, as long as Outlook is already open, a window with a new message addressed to you at mail@address.com will appear.
"C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE" /c IPM.note /m email@address.com
You can then press the key combination you assign to the shortcut and, as long as Outlook is already open, a window with a new message addressed to you at mail@address.com will appear.
ASKER
Let me chew on this - interesting
In the event you want a VBA Macro you can put on the Ribbon, use the following code
The top 4 lines determine your email address and it is inserted at the .To = tofield so the code can be shared with others without hard-coded email addresses.
Public Sub NotesToMyself()
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set olNS = OL.GetNamespace("MAPI")
tofield = olNS.Accounts.Item(1).SmtpAddress
With EmailItem
.Subject = "Note To Self"
.Body = "[Enter your message here]" & vbCrLf & _
"" & vbCrLf & _
.To = tofield
.Importance = olImportanceNormal
.Send
End With
End Sub
The top 4 lines determine your email address and it is inserted at the .To = tofield so the code can be shared with others without hard-coded email addresses.
ASKER
This link provides info on enabling macros in Outlook.
How to enable and disable macros in Outlook?
»bp
How to enable and disable macros in Outlook?
»bp
ASKER
Darrel,
Have you tested this code. I get all types of problem. I do have Option Explicit enabled.
Have you tested this code. I get all types of problem. I do have Option Explicit enabled.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all. Bill, I can now study this code. Appreciate everyone
Welcome Frank, hope you get something that works well for you.
»bp
»bp
Bill, nice work! I literally just hacked something together from toilet paper and white glue and you polished it into something splendid. Thank you!
If you really want to just click a key combo and have your email filled in then I might look outside Outlook, at a keyboard automation tool. I purchased KeyText a while back and use it for some similar tasks, but it isn't free. There are others though, a few mentioned below but Google will probably find you more...
»bp