Macro to add text to a Message

Status
Not open for further replies.
E

Emma Aumack

Hi all,

Although I have used VBA in Excel, I have never used it in Outlook. Using

Outlook 2007, What I would like to do seems simple enough but I have no clue

how to do it. All I want to do is add text to the body of a message. I

thought something like this would work but I get the error message "Sub of

Function not defined". I know I'm missing an event or something but I'm not

sure. Can someone please help?

Sub APPRVL_REQ_TEXT()

Dim Aprvl_Text As String

Aprvl_Text = "Your approval is requested for the following contract

renewals. Please also see sales data below:"

End Sub

www.bardpv.com

Tempe, Arizona
 
E

Emma Aumack

Ok. I've gotten this far but this code opens a new message. I want to

insert text into an existing open message and I am still getting the "sub or

function not defined error" when I try to run the macro. But I don't get it

when I "step into" the macro.

Sub APPRVL_REQ_TEXT()

Dim msg As Outlook.MailItem

Dim ApprovalText As String

ApprovalText = "Your approval is requested for the following contract

renewals. Please also see sales data below:"

Set msg = Application.CreateItem(olMailItem)

msg.Body = ApprovalText

msg.Display

Set msg = Nothing

End Sub

Any help would be greatly appreciated.

Emma

www.bardpv.com

Tempe, Arizona

"Emma Aumack" wrote:


> Hi all,

> Although I have used VBA in Excel, I have never used it in Outlook. Using
> Outlook 2007, What I would like to do seems simple enough but I have no clue
> how to do it. All I want to do is add text to the body of a message. I
> thought something like this would work but I get the error message "Sub of
> Function not defined". I know I'm missing an event or something but I'm not
> sure. Can someone please help?

> Sub APPRVL_REQ_TEXT()

> Dim Aprvl_Text As String

> Aprvl_Text = "Your approval is requested for the following contract
> renewals. Please also see sales data below:"

> End Sub

> > www.bardpv.com
> Tempe, Arizona
 
S

Sue Mosher [MVP]

How are you trying to run the macro when you get the error?

To return the currently open item in Outlook VBA, use

Application.ActiveInspector.CurrentItem.

Sue Mosher

"Emma Aumack" wrote:


> Ok. I've gotten this far but this code opens a new message. I want to
> insert text into an existing open message and I am still getting the "sub or
> function not defined error" when I try to run the macro. But I don't get it
> when I "step into" the macro.

> Sub APPRVL_REQ_TEXT()

> Dim msg As Outlook.MailItem
> Dim ApprovalText As String

> ApprovalText = "Your approval is requested for the following contract
> renewals. Please also see sales data below:"
> Set msg = Application.CreateItem(olMailItem)
> msg.Body = ApprovalText
> msg.Display
> Set msg = Nothing
> End Sub

> Any help would be greatly appreciated.

> Emma

> > www.bardpv.com
> Tempe, Arizona

> "Emma Aumack" wrote:
>
> > Hi all,
> > Although I have used VBA in Excel, I have never used it in Outlook. Using
> > Outlook 2007, What I would like to do seems simple enough but I have no clue
> > how to do it. All I want to do is add text to the body of a message. I
> > thought something like this would work but I get the error message "Sub of
> > Function not defined". I know I'm missing an event or something but I'm not
> > sure. Can someone please help?
> > Sub APPRVL_REQ_TEXT()
> > Dim Aprvl_Text As String
> > Aprvl_Text = "Your approval is requested for the following contract
> > renewals. Please also see sales data below:"
> > End Sub
> > > > www.bardpv.com
> > Tempe, Arizona
 
E

Emma Aumack

Just from the macros icon in the developer menu.

Also, I tried to get into the macro today and now I get an error message

that says "The macros in this project are disabled. Please refer to the

onlin ehelp or documentation of the host application to determine how to

enable macros." So I looked online and the help says to open the document

with Enable Macros but NOWHERE do I see how to enable macros in a project.

www.bardpv.com

Tempe, Arizona

"Sue Mosher [MVP]" wrote:


> How are you trying to run the macro when you get the error?

> To return the currently open item in Outlook VBA, use
> Application.ActiveInspector.CurrentItem.
> > Sue Mosher
> > >

> "Emma Aumack" wrote:
>
> > Ok. I've gotten this far but this code opens a new message. I want to
> > insert text into an existing open message and I am still getting the "sub or
> > function not defined error" when I try to run the macro. But I don't get it
> > when I "step into" the macro.
> > Sub APPRVL_REQ_TEXT()
> > Dim msg As Outlook.MailItem
> > Dim ApprovalText As String
> > ApprovalText = "Your approval is requested for the following contract
> > renewals. Please also see sales data below:"
> > Set msg = Application.CreateItem(olMailItem)
> > msg.Body = ApprovalText
> > msg.Display
> > Set msg = Nothing
> > End Sub
> > Any help would be greatly appreciated.
> > Emma
> > > > www.bardpv.com
> > Tempe, Arizona
> > "Emma Aumack" wrote:
> >
> > > Hi all,
> > > > Although I have used VBA in Excel, I have never used it in Outlook. Using
> > > Outlook 2007, What I would like to do seems simple enough but I have no clue
> > > how to do it. All I want to do is add text to the body of a message. I
> > > thought something like this would work but I get the error message "Sub of
> > > Function not defined". I know I'm missing an event or something but I'm not
> > > sure. Can someone please help?
> > > > Sub APPRVL_REQ_TEXT()
> > > > Dim Aprvl_Text As String
> > > > Aprvl_Text = "Your approval is requested for the following contract
> > > renewals. Please also see sales data below:"
> > > > End Sub
> > > > > > > > www.bardpv.com
> > > Tempe, Arizona
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
L Outlook 2007 Macro to Add Text to a Contact Field Using Outlook 10
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 8
C Macro to add multiple recipients to message Outlook VBA and Custom Forms 3
M Macro to add date/time stamp to subject Outlook VBA and Custom Forms 4
S Example VBA Macro - To Conditionally Change the From Account and Add a BCC Address on Emails Outlook VBA and Custom Forms 11
snhnic Macro that does not overwrite but add a number Outlook VBA and Custom Forms 1
A Email Macro to add Date and Classification Outlook VBA and Custom Forms 2
W Macro to add a word in Subject Line Using Outlook 1
L Macro to Add Catgegory to List of Contacts Using Outlook 4
W Add to Calendar links - auto accept with macro Using Outlook 1
B Auto BCC VBA macro: how to add exceptions? Using Outlook 28
M How to Create Macro in Visual Basic to add Contacts from Personal Folder Using Outlook 4
P How do I create a macro to add contacts from email messages? Outlook VBA and Custom Forms 1
D Call add-in method from macro? Outlook VBA and Custom Forms 1
S HTML to Plain Text Macro - Help Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1
N Help creating a VBA macro with conditional formatting to change the font color of all external emails to red Outlook VBA and Custom Forms 5
S Visual indicator of a certain property or to show a macro toggle Outlook VBA and Custom Forms 2
L Modifying VBA script to delay running macro Outlook VBA and Custom Forms 3
S Macro to extract and modify links from emails Outlook VBA and Custom Forms 3
M Replyall macro with template and auto insert receptens Outlook VBA and Custom Forms 1
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
Globalforester ItemAdd Macro - multiple emails Outlook VBA and Custom Forms 3
S Macro to extract email addresses of recipients in current drafted email and put into clipboard Outlook VBA and Custom Forms 2
witzker HowTo start a macro with an Button in OL contact form Outlook VBA and Custom Forms 12
witzker Macro to move @domain.xx of a Spammail to Blacklist in Outlook 2019 Outlook VBA and Custom Forms 7
S Macro for other actions - Outlook 2007 Outlook VBA and Custom Forms 23
C Macro to extract sender name & subject line of incoming emails to single txt file Outlook VBA and Custom Forms 3
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
S Macro to move “Re:” & “FWD:” email recieved the shared inbox to a subfolder in outlook Outlook VBA and Custom Forms 0
S Outlook Macro to send auto acknowledge mail only to new mails received to a specific shared inbox Outlook VBA and Custom Forms 0
S Outlook Macro to move reply mail based on the key word in the subjectline Outlook VBA and Custom Forms 0
Eike Move mails via macro triggered by the click of a button? Outlook VBA and Custom Forms 0
S Macro or plug-in to see if specific person was included in this email Outlook VBA and Custom Forms 4
U Macro for reminders,tasks,calendar Outlook VBA and Custom Forms 4
V macro runs slower on startup than after Outlook VBA and Custom Forms 3
N Macro to move all recipients to CC while replying Outlook VBA and Custom Forms 0
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
G VBA Macro Using Outlook 4
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
R Macro Schedule every day in Outlook Using Outlook 0
L Moving emails with similar subject and find the timings between the emails using outlook VBA macro Outlook VBA and Custom Forms 1
Healy Consultants Macro to remove inside organization distribution list email address when reply to all recepients Outlook VBA and Custom Forms 0
geofferyh Cannot get Macro to SAVE more than one message attachment??? Outlook VBA and Custom Forms 5
N How can I increase/faster outlook VBA Macro Speed ? Using Outlook 2
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
D.Moore Folder view settings by VBA macro Outlook VBA and Custom Forms 57
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3

Similar threads

Top