View Single Post
  #1  
Old March 3rd 06, 06:00 PM posted to microsoft.public.outlook.program_vba
WMR
external usenet poster
 
Posts: 2
Default Mailing a sheet without saving before

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