A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Mailing a sheet without saving before



 
 
Thread Tools Search this Thread Display Modes
  #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
  #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

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

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  
Old March 3rd 06, 07:42 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

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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


All times are GMT +1. The time now is 08:45 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.