B
BillyRogers
I'm trying to send an open spreadsheet as an attachment from code in Outlook
2003. I tried using the excel command SendMail but that triggers a security
warning.
The code fails when I try to add the workbook as an attachment.
Sub temp()
Dim xlApp As New Excel.Application
Dim appwbook As Excel.Workbook
Dim appwsheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set appwbook = xlApp.Workbooks.Add
Set appwsheet = appwbook.Worksheets(1)
xlApp.Visible = True
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
objMail.BodyFormat = olFormatHTML
objMail.Recipients.Add ("(e-mail address removed)")
objMail.Subject = "this is the subject"
objMail.Attachments.Add (appwbook) ' ** this line doesn't work!!!
objMail.Display
End Sub
--
Billy Rogers
Dallas,TX
Currently Using Office 2000 and Office 2003
2003. I tried using the excel command SendMail but that triggers a security
warning.
The code fails when I try to add the workbook as an attachment.
Sub temp()
Dim xlApp As New Excel.Application
Dim appwbook As Excel.Workbook
Dim appwsheet As Excel.Worksheet
Set xlApp = New Excel.Application
Set appwbook = xlApp.Workbooks.Add
Set appwsheet = appwbook.Worksheets(1)
xlApp.Visible = True
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
objMail.BodyFormat = olFormatHTML
objMail.Recipients.Add ("(e-mail address removed)")
objMail.Subject = "this is the subject"
objMail.Attachments.Add (appwbook) ' ** this line doesn't work!!!
objMail.Display
End Sub
--
Billy Rogers
Dallas,TX
Currently Using Office 2000 and Office 2003