Pre populate subject + body + attachment to already open email in outlook 2007

Status
Not open for further replies.

Sharpie

Member
Outlook version
Email Account
POP3
Hi. I have created a complex excel workbook which ends up by creating a file and placing it on the desktop.

The last action of Excel opens an e mail addressed to the enquirer.

See code: (G4 contains the enquirer's address, which was typed in earlier).

Private Sub CommandButton1_Click() Range("G4").Select Selection.Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True End Sub

Now that a new Outlook mail is open and addressed, I want to be able to run a macro from a button on the quick access bar which fills in the subject line, body copy, and attaches the file, from the desktop and sends the e mail.

The subject line and body will aways be the same and the name of the attachment will always be the same. (though it will not have the same content).

So one click in Excel launches a new email, addressed to the enquirer and this already works fine. The next click is the macro button on the Outlook quick access bar.

This is what I'm having trouble with.

Here's the code I attached to the Outlook button.

Sub inspector()

Dim myOlApp As New Outlook.Application

Dim myItem As Object

Dim myAttachments As Outlook.Attachments

Set myItem = myOlApp.ActiveInspector.currentitem

Set myAttachments = myItem.Attachments

myItem.Subject = "subject"

myItem.Body = "body"

myAttachments.Add "C:\ etc \etc\

myItem.Display

End Sub I get the error - run time error 424 object required. I'm confused, please can you help? Many Thanks
 
Re: Pre populate subject + body + attachment to already open email in outlook

Why not do all that from the original macro in Excel?

You need to Set objApp = Outlook.Application. Or use

Set myItem = Application.ActiveInspector.CurrentItem

Because the message is open, you don't need to use New -

Dim myOlApp As Outlook.Application
 
Re: Pre populate subject + body + attachment to already open email in outlook

Thankyou Diane. I think I understand. I'll won't get a chance to try it for a couple of days. I'll let you know how I get on.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A GetSelectNamesDialog Pre-fill search box Outlook VBA and Custom Forms 12
S Creating Email - Selecting Pre-Defined Text Using Outlook 2
O "Pre-filled" text in each new message Using Outlook 2
F VBScript to add pre defined text Using Outlook 5
S Catch events from pre-existing buttons in Outlook 2007 Outlook VBA and Custom Forms 7
J User defined fields with pre-defined values Outlook VBA and Custom Forms 3
C Populate form data into message body Outlook VBA and Custom Forms 1
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
B Outlook 365 Populate Outlook Task UDFs from a UDF text string Outlook VBA and Custom Forms 2
D Cannot populate certain UserProperties in Outlook from Excel Outlook VBA and Custom Forms 2
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
C Trying to populate an appointment ComboBox from Excel Outlook VBA and Custom Forms 2
A Populate Listbox from Txt File Outlook VBA and Custom Forms 0
A Populate Textbox from Txt File Outlook VBA and Custom Forms 1
M Adding Macro to populate "to" "subject" "body" not deleting email string below. Outlook VBA and Custom Forms 5
Diane Poremsky Outlook VBA: Use a Text File to Populate a ListBox Using Outlook 0
T populate calendar with appointments and send reminders Using Outlook 1
A Populate Excel from Outlook Userform Outlook VBA and Custom Forms 3
J Live Meeting Location populate from body Outlook VBA and Custom Forms 4
A How can I populate a dropdown list? BCM (Business Contact Manager) 4
rohit I want to Populate Popup box while sending any email with attachment. Outlook VBA and Custom Forms 4
rohit I want to Populate Popup box while sending any email with attachment Using Outlook 1
A Cannot populate IMAP folders Using Outlook 1
S Populate textbox values from one form to another form. Using Outlook 0
B Auto Populate From Field Using Outlook 3
G Populate an Outlook 2007 template with spreadsheet data. Outlook VBA and Custom Forms 1
R Populate Form with appointments from Calendar Outlook VBA and Custom Forms 1
J populate word template from Outlook custom form Outlook VBA and Custom Forms 2
G Populate BCC field with all Contacts within a Contact Folder Outlook VBA and Custom Forms 4
M Create new Contacts folder and populate it from Access Outlook VBA and Custom Forms 1
A Macro - Open new message, populate from and subject fields, and message text Outlook VBA and Custom Forms 1
G Macro: Create New Message and Auto populate To Field Outlook VBA and Custom Forms 5
S populate body with Word data Outlook VBA and Custom Forms 7
L how to populate multiple users contacts Outlook VBA and Custom Forms 9
A Populate task field based on value of other field Outlook VBA and Custom Forms 9
H using VBA to edit subject line Outlook VBA and Custom Forms 0
F Auto changing email subject line in bulk Using Outlook 2
M Outlook Macro to save as Email with a file name format : Date_Timestamp_Sender initial_Email subject Outlook VBA and Custom Forms 0
J Outlook 365 Forward Email Subject to my inbox when new email arrive in shared inbox Using Outlook 0
sjmo2 Change subject for new e-mails only. Outlook VBA and Custom Forms 2
C Outlook 365 Copy/Save Emails in Folder Outside Outlook to Show Date Sender Recipient Subject in Header Using Outlook 0
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
ill13 Prepend the user's computer name to the subject. Outlook VBA and Custom Forms 1
D Auto Remove [EXTERNAL] from subject - Issue with Macro Using Outlook 21
2 How to get rid of the "Emailing:" prefix in the subject line Using Outlook 1
S Outlook Macro for [Date][Subject] Using Outlook 1
O How to find and replace a word in Outlook-Agenda-Subject and Message? Using Outlook 0
D ISOmacro to extract active mail senders name and email, CC, Subject line, and filename of attachments and import them into premade excel spread sheet Outlook VBA and Custom Forms 2
C Outlook 365 Subject Prefixes? Outlook VBA and Custom Forms 1
A Macro to file emails into subfolder based on subject line Outlook VBA and Custom Forms 1

Similar threads

Back
Top