ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code to add attachment (https://www.excelbanter.com/excel-programming/417261-code-add-attachment.html)

Lynda

Code to add attachment
 
Hi Everybody, I am probably stretching the friendship here but I thought I
would ask anyway. I have created a form in excel 2003 with the submit button
to send by email. What I want to know is is it possible to have another
button on the form to add an attachment and then hit the submit button and
have both the form and attachment sent by email.
Thanks in advance for any assistance.

Lynda

[email protected]

Code to add attachment
 
On Sep 18, 6:34*am, Lynda wrote:
Hi Everybody, I am probably stretching the friendship here but I thought I
would ask anyway. I have created a form in excel 2003 with the submit button
to send by email. What I want to know is is it possible to have another
button on the form to add an attachment and then hit the submit button and
have both the form and attachment sent by email.
Thanks in advance for any assistance.

Lynda


Hi Lynda:

You can try playing with this code, I use it for a script to filter
data into multiple workbooks and attach them to email messages. Note -
you cannot have a signature and provide text for the body of the email
programmatically (at least, I have never been successful doing so), it
is one or the other.


Steven

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "RecipientAddress"
.CC = "CarbonCopyAddress"
.BCC = "BlindCarbonCopyAddress"
.Subject = "Your subject here"
.Attachments.Add ActiveWorkbook.FullName
'Attaches active workbook
.Display 'Displays the processed email. You
can change this to .Send
End With
On Error GoTo 0


Lynda

Code to add attachment
 
Thank you Steven, that was what i was looking for.

" wrote:

On Sep 18, 6:34 am, Lynda wrote:
Hi Everybody, I am probably stretching the friendship here but I thought I
would ask anyway. I have created a form in excel 2003 with the submit button
to send by email. What I want to know is is it possible to have another
button on the form to add an attachment and then hit the submit button and
have both the form and attachment sent by email.
Thanks in advance for any assistance.

Lynda


Hi Lynda:

You can try playing with this code, I use it for a script to filter
data into multiple workbooks and attach them to email messages. Note -
you cannot have a signature and provide text for the body of the email
programmatically (at least, I have never been successful doing so), it
is one or the other.


Steven

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "RecipientAddress"
.CC = "CarbonCopyAddress"
.BCC = "BlindCarbonCopyAddress"
.Subject = "Your subject here"
.Attachments.Add ActiveWorkbook.FullName
'Attaches active workbook
.Display 'Displays the processed email. You
can change this to .Send
End With
On Error GoTo 0




All times are GMT +1. The time now is 09:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com