ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   E-mail macro (https://www.excelbanter.com/excel-discussion-misc-queries/46681-e-mail-macro.html)

greg7468

E-mail macro
 

Hi all,
I have a workbook that I send out daily to a contact list within
outlook.

What is the best way of doing this with a macro to work off a button on
the worksheet.

Thanks in advance.


--
greg7468


------------------------------------------------------------------------
greg7468's Profile: http://www.excelforum.com/member.php...fo&userid=9031
View this thread: http://www.excelforum.com/showthread...hreadid=469881


Chad

Here's how to send a workbook from Excel as an attachment:

Create a macro with the code below and then create a button that calls that
macro. Keep in mind you must add a reference to the Microsoft outlook
Library (Tools\References).

'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Dim strbody As String

strbody = "here is the workbook"
With OutMail
.To = " 'or whatever your recipients name
'.CC = "" 'if any
'.BCC = 'if any
.Subject = "here"
.Body = strbody
'define attachment
attachmentname = "C:\Documents and Settings\All
Users\Desktop\Book1.xls" 'your path
Set myAttachments = OutMail.Attachments
myAttachments.Add attachmentname
.Display 'or use .Send to bypass the display
End With

Hope this helps!
-Chad

"greg7468" wrote:


Hi all,
I have a workbook that I send out daily to a contact list within
outlook.

What is the best way of doing this with a macro to work off a button on
the worksheet.

Thanks in advance.


--
greg7468


------------------------------------------------------------------------
greg7468's Profile: http://www.excelforum.com/member.php...fo&userid=9031
View this thread: http://www.excelforum.com/showthread...hreadid=469881




All times are GMT +1. The time now is 07:05 AM.

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