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

using letter template



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 8th 07, 09:27 PM posted to microsoft.public.outlook.program_vba
Ludo
external usenet poster
 
Posts: 5
Default using letter template

Hi,

I use following code to create a mail using Outlook from within Excel.
I created a template file (BeLUG vzw.htm) that resides in :
C:\Program Files\Common Files\Microsoft Shared\Letter

Now, i need to use this specific letter template.

Question is: what code lines do i need to add to the code here below
to create a mail with the desired letter template?

Sub Mail_workbook_Outlook_1()
'Working in 2000-2007
' source : http://www.rondebruin.nl/tips.htm

Dim OutApp As Object
Dim OutMail As Object
Const sMsg2 = "Send methode = Outlook"

szSection = "Expence"
szKey = "Mail Address1"
MailTo1 = GetIniKey(szFile, szSection, szKey)
szKey = "Mail Address2"
MailTo2 = GetIniKey(szFile, szSection, szKey)

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next

With OutMail
.To = MailTo1
If MailTo2 "0" Then
.CC = MailTo2
End If

.Subject = wbName
.Body = sMsg & vbCrLf & sMsg2
.Attachments.Add wbPathName
.Display '.Send '
End With

On Error GoTo 0
OutApp.Session.Logoff
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Thanks for any help.
Regards,
Ludo

  #2  
Old October 9th 07, 05:32 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default using letter template



Instead of creating the item with the CreateItem function, use the
GetItemFromTemplate function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Organize eMails:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Mon, 08 Oct 2007 13:27:57 -0700 schrieb Ludo:

Hi,

I use following code to create a mail using Outlook from within Excel.
I created a template file (BeLUG vzw.htm) that resides in :
C:\Program Files\Common Files\Microsoft Shared\Letter

Now, i need to use this specific letter template.

Question is: what code lines do i need to add to the code here below
to create a mail with the desired letter template?

Sub Mail_workbook_Outlook_1()
'Working in 2000-2007
' source : http://www.rondebruin.nl/tips.htm

Dim OutApp As Object
Dim OutMail As Object
Const sMsg2 = "Send methode = Outlook"

szSection = "Expence"
szKey = "Mail Address1"
MailTo1 = GetIniKey(szFile, szSection, szKey)
szKey = "Mail Address2"
MailTo2 = GetIniKey(szFile, szSection, szKey)

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next

With OutMail
.To = MailTo1
If MailTo2 "0" Then
.CC = MailTo2
End If

.Subject = wbName
.Body = sMsg & vbCrLf & sMsg2
.Attachments.Add wbPathName
.Display '.Send '
End With

On Error GoTo 0
OutApp.Session.Logoff
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Thanks for any help.
Regards,
Ludo

  #3  
Old October 9th 07, 12:27 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default using letter template

A better solution might be to create the message and save it as an .oft file template, so you can use the CreateItemFromTemplate method with it as Michael suggested. If what you have is an HTML file, you can apply that file as stationery using the technique shown he http://blogs.officezealot.com/legaul...7/21/7581.aspx

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Ludo" wrote in message ups.com...
Hi,

I use following code to create a mail using Outlook from within Excel.
I created a template file (BeLUG vzw.htm) that resides in :
C:\Program Files\Common Files\Microsoft Shared\Letter

Now, i need to use this specific letter template.

Question is: what code lines do i need to add to the code here below
to create a mail with the desired letter template?

Sub Mail_workbook_Outlook_1()
'Working in 2000-2007
' source : http://www.rondebruin.nl/tips.htm

Dim OutApp As Object
Dim OutMail As Object
Const sMsg2 = "Send methode = Outlook"

szSection = "Expence"
szKey = "Mail Address1"
MailTo1 = GetIniKey(szFile, szSection, szKey)
szKey = "Mail Address2"
MailTo2 = GetIniKey(szFile, szSection, szKey)

Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next

With OutMail
.To = MailTo1
If MailTo2 "0" Then
.CC = MailTo2
End If

.Subject = wbName
.Body = sMsg & vbCrLf & sMsg2
.Attachments.Add wbPathName
.Display '.Send '
End With

On Error GoTo 0
OutApp.Session.Logoff
Set OutMail = Nothing
Set OutApp = Nothing
End Sub

Thanks for any help.
Regards,
Ludo

 




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
Word Letter Template loses Page Setup Geoff Goodacre Outlook - Using Contacts 0 July 4th 07 05:18 PM
Creating custom template to use as corp New mail message template Lars JJ Outlook - Using Forms 8 May 15th 07 08:32 AM
Cannot use my company logo in `send letter to contact' word template BT-Steve Outlook - Fax Functions 3 March 2nd 07 08:36 PM
News Letter [email protected] Outlook Express 3 January 26th 07 02:11 PM
letter Bruce Hagen Outlook Express 3 September 6th 06 09:34 PM


All times are GMT +1. The time now is 10:36 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.