Start a mailtemplate with a makro

  • Thread starter Thread starter E.Zenker
  • Start date Start date
E

E.Zenker

Hi
I would need the macrocode to start the Mailtemplate TEST.oft from an OL
contact with a botton and write in the mailadresse of the contact - like the
function 'new message to contact.'

Thanks for ideas
E.Zenker
 
Thanks for answer
But i dont know how to start
i cannot find an example of Namespace.CreateItemFromTemplate
and i cannot handle it.

can you please tell me the code how to open the template TEST.oft
Thanks for care
 
When in doubt, check the object browser: Press ALt+F11 to open the VBA
environment in Outlook, then press F2. Switch from <All Libraries> to
Outlook to browse all Outlook objects and their properties, methods, and
events. Select any object or member, then press F1 to see its Help topic.
There you'll find sample code showing you exactly how to use this method.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Hi Ewald,

in addition to Sue: As you mentioned in an earlier post in de.outlook,
you have already CommandBarButtons and functions for calling several
Word documents. This and some posts, I´ve read from you in the past two
years, I´m sure you *could* easily know where to start. Please don´t
forget, newsgroups are for helping only - the work you have to do
yourself.
 
Thanks
I did what you recommended but I am sorry I can only find NameSpace Create
Recipient.
How do I find Namespace.CreateItemFromTemplate?

Thank you
E. Zenker
 
Hi Michael

Thanks for your reply

Thanks to sues example i have modified her code to fit for my templates.
Here ist the code i have.

'Pushing Contact data to Word documents, using bookmarks.
'Button 1 = Erstunterlagen pers
Sub Erstunterlagen_pers_Click

'Einfügen Datum Erstunterlagen pers. verschickt
Item.Body = Item.Body & Date() & " Erstunterlagen pers. verschickt" & vbCrLf

Dim strLetter
Dim strDate
Dim objWord
Dim objDocs
Dim rng

'Datum einlesen
'strDate = CStr(Date())
'MsgBox "Date: " & strDate

'Pfad zur Vorlage
strLetter = "C:\Dokumente und
Einstellungen\USER\Anwendungsdaten\Microsoft\Vorlagen\Briefe direkt aus OL\1
Erstunterlagen pers.dot"

'Open Word invisibly
Set objWord = Item.Application.CreateObject("Word.Application")

'Nachricht anzeigen
'MsgBox "Dieser Brief muss nach dem drucken" & vbCrLf & "nicht
gespeichert werden", 64, "WORD wird geöffnet"

'Open a new letter based on the selected template
Set objDocs = objWord.Documents
objDocs.Add strLetter
objWord.Visible = True

'Textmarken mit OLFeldern beschreiben
objWord.ActiveDocument.Bookmarks("Abteilung").Select
objWord.Selection.TypeText Item.Department

objWord.ActiveDocument.Bookmarks("Anrede").Select
objWord.Selection.TypeText Item.Title

objWord.ActiveDocument.Bookmarks("Anrede1").Select
objWord.Selection.TypeText Item.Title


objWord.ActiveDocument.Bookmarks("Firma").Select
objWord.Selection.TypeText Item.CompanyName

objWord.ActiveDocument.Bookmarks("Land").Select
objWord.Selection.TypeText Item.BusinessAddressCountry


objWord.ActiveDocument.Bookmarks("Name").Select
objWord.Selection.TypeText Item.LastName

objWord.ActiveDocument.Bookmarks("Name1").Select
objWord.Selection.TypeText Item.LastName


objWord.ActiveDocument.Bookmarks("Ort").Select
objWord.Selection.TypeText Item.BusinessAddressCity

objWord.ActiveDocument.Bookmarks("PLZ").Select
objWord.Selection.TypeText Item.BusinessAddressPostalCode

objWord.ActiveDocument.Bookmarks("Strasse").Select
objWord.Selection.TypeText Item.BusinessAddressStreet
'??
Set rng = objWord.ActiveDocument.Range(0, 0)
rng.Select
objWord.Activate

End Sub

Now i want to do exactly the same but not print this letter. I want to sent
it
to the email contact like above per mail.
It would be great, if you could help me to modify the code in that way,
that the email-address is put in automatically in the "To" field.
In the from field should be my email adress.

Thanks for your attention and care.
E. Zenker


----------------------------------------
 
What version of Outlook? Send the letter as an attachment or as the message
body?
 
But there are two ways to send a Word document as an email message -- as the
body of the message and as an attachment. Which do you want to do?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
As the body
Sue Mosher said:
But there are two ways to send a Word document as an email message -- as
the body of the message and as an attachment. Which do you want to do?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
To do that, you use the Document.MailEnvelope property:

Set objDoc = objWord.ActiveDocument
Set objEnv = objDoc.MailEnvelope ' Office.MsoEnvelope
Set objMail = objEnv.Item ' Outlook.MailItem
With objMail
.Subject = Replace(objDoc.Name, ".doc", "", , , vbTextCompare)
.To = "(e-mail address removed)"
.Send
End With

Note that the Send statement will trigger an Outlook security prompt. See
http://www.outlookcode.com/d/sec.htm for your options with regard to the
"object model guard" security in Outlook 2000 SP2 and later versions.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top