View Single Post
  #2  
Old March 3rd 06, 06:05 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Mailing a sheet without saving before

That's not possible. Outlook can only attach a file programmatically if it has first been saved.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"WMR" wrote in message ...
Hello,

I made a program in Excel that mails the Activesheet.
For each email I add the name of the repicient. So it is personalized. I
want to use a specific Outlook template.

To do this, I have to save my Excelsheet first. But that takes a lot of time.
So, I want to send my email without saving.

I use the following code.

Sub SendMyEmail()

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate _
("C:\Templates\WMR.oft")

Set wb = Workbooks(Active_Excel_File)
With wb
.SaveAs "C:\Temp\" & MySubject & " " & MyDate & ".xls"

With OutMail
.To = email
.Subject = MySubject & " " & MyDate
.Attachments.Add wb.FullName
.Send
End With

.ChangeFileAccess xlReadOnly

Kill wb.FullName

Set OutMail = Nothing
Set OutApp = Nothing

End With

End Sub

Who can help me out?
Thanks a lot!

Willem

Ads