ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Problem (https://www.excelbanter.com/excel-programming/289488-macro-problem.html)

Al Jager

Macro Problem
 
Sub SendMail()
Dim objOutlook As Object
Dim objMailItem As Object
Dim objRecipient As Object


Set objOutlook = CreateObject("Outlook.Application")

Set objMailItem = objOutlook.CreateItem(0)
Set objRecipient = objMailItem.Recipients.Add _
(ActiveSheet.Range("B2").Value)


objRecipient.Type = 1 '1 = To, use 2 for cc
objMailItem.Subject = "The extract has finished."

'Instead of the path to the file - I want to insert Active
Workbook in the next line
objMailItem.Attachments.Add _
("C:\Al Jager\! BookTest1.xls")
objMailItem.Display 'change to .Send if you don't
want to interact

End Sub


All times are GMT +1. The time now is 10:38 AM.

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