![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]()
OK, but...
If I use this statement, it works well: ActiveWorkbook.SendMail Recipients:=MyEmailAddresses, Subject:= MySubject but I do not get C:\Templates\WMR.oft. My Excelsheet is attached, but with a blank body. Maybe you can help me further. Tanks Willem "Sue Mosher [MVP-Outlook]" wrote: 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 |
#4
|
|||
|
|||
![]()
SendMail uses a different mechanism that doesn't invoke Outlook directly. If you want Outlook functionality, you have to play by Outlook's rules. In this case, that means saving the file before attaching it.
-- 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 ... OK, but... If I use this statement, it works well: ActiveWorkbook.SendMail Recipients:=MyEmailAddresses, Subject:= MySubject but I do not get C:\Templates\WMR.oft. My Excelsheet is attached, but with a blank body. Maybe you can help me further. Tanks Willem "Sue Mosher [MVP-Outlook]" wrote: That's not possible. Outlook can only attach a file programmatically if it has first been saved. "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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
mailing pictures | dalenherb | Outlook Express | 15 | March 4th 06 11:52 PM |
creating a fax cover sheet from outlook | Sandman | Outlook - Using Contacts | 2 | February 21st 06 04:15 PM |
Mailing labels and merging | KathrynBassett | Outlook - Using Contacts | 3 | February 15th 06 11:26 PM |
How do I print some Outlook Contacts to a sheet of 3 x 5 Index Car | tinacscs | Outlook - Using Contacts | 1 | February 3rd 06 12:31 AM |
allow me to print a fax cover sheet directly from a contact's info | kdzzack | Outlook - Using Contacts | 0 | January 30th 06 07:31 PM |