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

Status
Not open for further replies.

Sharpie

Member
Outlook version
Outlook 2007
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

Sharpie

Member
Outlook version
Outlook 2007
Email Account
POP3
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.
Thread starter Similar threads 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
L Trying to install pre-req for Exchange SP1 Exchange Server Administration 17
L Exchange 2010 SP1 Pre-Req error Exchange Server Administration 2
D outlook pre-view pane changed yesterday Using Outlook 4
S Microsoft India Pre-Sales Support Feedback Exchange Server Administration 1
S Pre-Deployment Analyzer Exchange Server Administration 8
S 2003: Issue dragging & dropping a Task or Email to pre-selected Cal. timeslot Using Outlook 3
T Management Tools Pre Requisites Exchange Server Administration 2
S Pre SP1 using Managed Folders Policy - Post SP1 what do I do? Retention Policy? Exchange Server Administration 2
P Error installing Exchange Pre-deployment Analyzer Exchange Server Administration 1
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 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 New Slipstick.com Articles 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
J calendar: populate multiple appointment subject fields at once Using Outlook 4
D Reply to a sender does not populate the To: Field Using Outlook 1
K Quickest way to populate email via IMAP up to a server. Using Outlook 1
M Exchange and IMAP Accounts: Populate Exchange Calendar with IMAP Meeting Requests Using Outlook 1
L Can't populate History of Business Contacts- receive 1st error: cannon load an object because it is not available, then 2nd: Cannot display this view Using Outlook 1
A Uploaded Outlook Contacts Will Not Populate Email Address Using Outlook 2
9 BCM 2010 populate created/due field for created Direct Mail Print Using Outlook 4
N Activities Tab does not populate with all linked activity 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
R Disable conversation thread from replying of recipients in the same subject. Please help Using Outlook 0
M Outlook 2013 Script Assistance - Save Opened Link with Subject Added Outlook VBA and Custom Forms 1
Similar threads


















































Top