Results 1 to 3 of 3

Thread: Template (2003)

  1. #1
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Template (2003)

    Hi, I am trying to find a way to automate Outlook from a button on the commandbar to do the following:

    Open a pre saved mail message, such as a notice to be sent to a distribution list. The foramt is HTML and includes images / lines and text etc. Then populate the subject and message body further with things like Dates and times etc, may use some inputboxes or a userform for more info, this can be inserted (I hope) by using the REPLACE function in VBA, to search out markers in the body and populate accordingly.

    I have this code so far:

    Sub openForm()
    Dim strTemplate As String, myItem As MailItem
    strTemplate = "E:temp.oft"
    Set myItem = Outlook.CreateItemFromTemplate(strTemplate)
    With myItem
    '.To = "surname, firstname"
    '.Recipients.ResolveAll
    '.Body = Replace(.Body, "<<TIME", "REPLACED")
    .Display
    End With
    Set myItem = Nothing
    End Sub

    It works ok-ish, but seems to add the signature BEFORE the body in the saved .oft file, which is rather annoying, also looks like the format jumps around when I do the REPLACE function.

    Any thoughts? Is the template file method the best way to do this or should I look more into forms?
    Thanks,

    pmatz

  2. #2
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Template (2003)

    With my O3K at work the signature problem doesn't happen, but as far as I can tell all the format settings are the same. The only difference is that at work I am on Exchange. Still can't stop the body format going funny when I run the replace command...
    Thanks,

    pmatz

  3. #3
    4 Star Lounger
    Join Date
    Aug 2003
    Location
    Stroud, United Kingdom
    Posts
    548
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Template (2003)

    Found out that using

    myItem.HTMLBody = REPLACE(myItem.HTMLBody,str1,str2) works fine for manipulating all aspects of the message.

    Sorted [img]/forums/images/smilies/smile.gif[/img] Still need to look at forms though I think.
    Thanks,

    pmatz

Posting Permissions

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