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

Adding an attachment to existing email



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 9th 09, 06:49 PM posted to microsoft.public.outlook.program_vba
Jason
external usenet poster
 
Posts: 117
Default Adding an attachment to existing email

I have a code that generates an email and fills in the subject/body. But
when I try and have it add an attachment, it generates 2 emails. Here is
what I have, how and where do I put the code to add a file as an attachment

Sub Macro1()



Dim olApp As Outlook.Application

Dim olMsg As Outlook.MailItem



Set olApp = Outlook.Application

Set olMsg = olApp.CreateItem(olMailItem)



With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

End With



Set olMsg = Nothing

Set olApp = Nothing

End Sub

Ads
  #2  
Old February 9th 09, 07:20 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Adding an attachment to existing email

With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

.Attachments.Add filePath 'filePath is the path and file name of the
attachment

End With


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"jason" wrote in message
...
I have a code that generates an email and fills in the subject/body. But
when I try and have it add an attachment, it generates 2 emails. Here is
what I have, how and where do I put the code to add a file as an
attachment

Sub Macro1()



Dim olApp As Outlook.Application

Dim olMsg As Outlook.MailItem



Set olApp = Outlook.Application

Set olMsg = olApp.CreateItem(olMailItem)



With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

End With



Set olMsg = Nothing

Set olApp = Nothing

End Sub


  #3  
Old February 9th 09, 07:46 PM posted to microsoft.public.outlook.program_vba
Jason
external usenet poster
 
Posts: 117
Default Adding an attachment to existing email

Thanks so much worked great

"Ken Slovak - [MVP - Outlook]" wrote:

With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

.Attachments.Add filePath 'filePath is the path and file name of the
attachment

End With


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"jason" wrote in message
...
I have a code that generates an email and fills in the subject/body. But
when I try and have it add an attachment, it generates 2 emails. Here is
what I have, how and where do I put the code to add a file as an
attachment

Sub Macro1()



Dim olApp As Outlook.Application

Dim olMsg As Outlook.MailItem



Set olApp = Outlook.Application

Set olMsg = olApp.CreateItem(olMailItem)



With olMsg



.Subject = "Hello world"

.Display

.Body = "Hello, here is my email!" & .Body

End With



Set olMsg = Nothing

Set olApp = Nothing

End Sub



 




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
Send existing email as attachment using vba Crossh Outlook and VBA 9 January 28th 09 03:48 PM
Email address dissapears when adding it to an existing contact Mimi Outlook - Using Contacts 9 January 8th 09 02:34 PM
Adding a contact from an existing email Nelson Outlook - Using Contacts 3 September 12th 08 03:17 AM
Problem adding attendees to existing appointment Lars Add-ins for Outlook 1 October 17th 06 05:56 PM
adding an attachment to a new email goes into the body of the emai jannetta pincusi Outlook - Using Forms 1 February 15th 06 02:31 PM


All times are GMT +1. The time now is 12:57 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.