A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Macro - Open new message, populate from and subject fields, and message text



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 14th 09, 04:56 PM
AndreaP AndreaP is offline
Junior Member
 
First recorded activity at Outlookbanter: Aug 2009
Posts: 1
Default Macro - Open new message, populate from and subject fields, and message text

Hello all,

I am trying to create a macro for Outlook 2003 that will open a new message, populate the From Field, populate the Subject field (these never change), and then populate the body of the email (which also never changes). I am very new to this. My goal is to steamline the process down to "click a button, get a populated email".

I have the first part:

Dim olkMsg As Outlook.MailItem
Set olkMsg = Application.CreateItem(olMailItem)
olkMsg.SentOnBehalfOfName = "Email address"
olkMsg.Subject = "My Subject"
olkMsg.Display

And the message:

Selection.TypeText Text:="Good morning,"
Selection.TypeParagraph
Selection.TypeParagraph

.... and so on

When I run the macro, the first part executes fine. I run into problems with the body of the email, because I keep getting the following error:

Run-time error '424': Object Required

What object should come between the first part of my macro and the text?

Thank you!

Last edited by AndreaP : August 14th 09 at 05:01 PM.
Ads
  #2  
Old August 14th 09, 06:27 PM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Macro - Open new message, populate from and subject fields, and message text



The Selection object refers to the Word library, Outlook doesn't know that.
You can use the Word library only in Outlook 2007, or if you have set to use
Word as email editor. In both cases you can access the email as a Word
Document object via the olkMsg.GetInspector.WordEditor property.

--
Best regards
Michael Bauer - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en



Am Fri, 14 Aug 2009 15:56:22 +0100 schrieb AndreaP:

Hello all,

I am trying to create a macro for Outlook 2003 that will open a new
message, populate the From Field, populate the Subject field (these
never change), and then populate the body of the email (which also
never changes). I am very new to this. My goal is to steamline the
process down to "click a button, get a populated email".

I have the first part:

Dim olkMsg As Outlook.MailItem
Set olkMsg = Application.CreateItem(olMailItem)
olkMsg.SentOnBehalfOfName = "Email address"
olkMsg.Subject = "My Subject"
olkMsg.Display

And the message:

Selection.TypeText Text:="Good morning,"
Selection.TypeParagraph
Selection.TypeParagraph

... and so on

When I run the macro, the first part executes fine. I run into problems
with the body of the email, because I keep getting the following error:

Run-time error '424': Object Required

What object should come between the first part of my macro and the
text?

Thank you!

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro: Create New Message and Auto populate To Field geosptial Outlook and VBA 5 August 14th 09 03:04 PM
Populate Message area with text from access database LenJr Outlook - Using Forms 1 August 4th 08 03:09 PM
Macro to populate contact fields no longer working RitaP Outlook and VBA 2 February 27th 07 07:45 PM
Outlook Macro to Modify Subject and Send Message jaysonsch Outlook and VBA 4 September 27th 06 06:48 AM
New message To, CC, BCC and Subject fields don't accept 'delete' [email protected] Outlook - General Queries 3 May 25th 06 08:34 PM


All times are GMT +1. The time now is 01:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.