Consulting

Results 1 to 5 of 5

Thread: Send mail (outlook) based on template stored in Access

  1. #1
    VBAX Newbie
    Joined
    Jun 2019
    Posts
    5
    Location

    Send mail (outlook) based on template stored in Access

    Hi there,
    I want to send a mail , using a template I stored in Access itself (WorkToDo.oft) . I have a small table "tbl_Sjablonen" in which I store my templates.
    I know the code for creating a mail based on a template, stored on e.g. "c:\L01" but I want to store the template files in my Access database (only 2 to 3 templates) .
    Can anyone show me the way?

    Thx in advance !
    Bob

  2. #2
    store the Template in an Attachment field.
    Extract it when you need to use it.

  3. #3
    VBAX Newbie
    Joined
    Jun 2019
    Posts
    5
    Location
    I have done that, it's a .otf (outlook template file) . But I want to create an email with that template file.
    Normally, the code for doing this (at least the one I know) =>

    NewMail
    = obApp.CreateItemFromTemplate("G:\Shared\test"[/COLOR])

    (with NewMail defined as MailItem and obApp as Object). But in stead of the "G:\shared\test" I want to use the template file stored in my table (as attachment Field).

    I could of course first extract the file (the *.otf) file to the disk and then create the new mail, and afterwards delete the file on disk.
    But this seems to me to be a workaround.

    In short the code would be something like : Set Newmail = obapp.createItemFromTemplate (...)
    with ... something that refers directly to a record of my table with all my templates (tabel of records with name and attachmentfield, the file itself) .
    This record has to be found before the creation of the mail of course, this is no problem.


    It works with extraction to Cl\L01, but I want to shortcut the extraction and set newmail... ("C:\L01\templatemail.otf")

    Thanks in advance for considering my question.
    Bob


  4. #4
    upload your db or show your code.
    basically, you create MailObject from your Template:

    Set newMail= objOutlook.CreateItemFromTemplate("C:\L01\templatemail.otf")

  5. #5
    VBAX Newbie
    Joined
    Jun 2019
    Posts
    5
    Location
    I save the template file in a folder on the computer ("C:\L01") and then I use it as template to create a mail.
    This works, thx anyway for your advise.
    (I was looking for a shorter way, but it works and that is the most important thing for my boss, so problem solved).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •