All-
I am trying to create a command button in Excel that when clicked, it will open up a new Outlook email message, input a certain address in the To: field, and input a specific Subject. The following is the code that I found online earlier today but it does not work when I paste it into the VBA editor.
Call SendEmail()
Function SendEmail()
Dim objOutlook, objMsg, objNameSpace, objFolder, strOutput, strSubject, StrTo, StrMsg
StrTo = "someone@somewhere.com"
StrMsg = InputBox ("Enter Your Message", "Enter Message", "Message Goes Here")
Const olMailItem = 0
Set objOutlook = CreateObject("Outlook.application")
Set objNameSpace = objOutlook.GetNameSpace("MAPI")
Set objMsg = objOutlook.CreateItem(olMailItem)
objMsg.To = StrTo
objMsg.Display
objMsg.HTMLBody = StrMsg
Set objFolder = Nothing
Set objNameSpace = Nothing
Set objOutlook = Nothing
Set objMsg = Nothing
Set ss = CreateObject("WScript.Shell")
Set ss = nothing
End Function
Now, the fact that it is getting an error could be my mistake since I have never created a VBA button before. Is there a basic crash course I can review for doing this and for inputting the code that is needed or can someone summarize it for me. Thank you for all of your help!
Bookmarks