Results 1 to 3 of 3

Thread: Change Font of Email Message Using Outlook automation

  1. #1

    Thread Starter
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    How do you set the font of a new email message? I'm using an outlook object to send email from my vb app, but I can't seem to change the font of the body of the message.

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,176

    Post

    To use different Fonts/Sizes or Colors the Text you use for the Body of the Message needs to be in Rich-Text Format.
    So you could use a RichTextbox to Create your Message in Whatever Format you require, then set the Messages Body Property to the RichTextbox's TextRTF Property, eg.
    Code:
    Private Sub Command1_Click()
        Dim oOutLook As New Outlook.Application
        Dim oMsg As Outlook.MailItem
        
        Set oMsg = oOutLook.CreateItem(olMailItem)
        oMsg.To = "Aaron Young"
        With RichTextBox1
            .Text = ""
            .SelFontName = "Arial"
            .SelFontSize = 48
            .SelColor = vbBlue
            .SelText = "Hi Aaron!!"
        End With
        oMsg.Body = RichTextBox1.TextRTF
        oMsg.Send
    End Sub

    ------------------
    Aaron Young
    Analyst Programmer
    aarony@redwingsoftware.com
    adyoung@win.bright.net

  3. #3

    Thread Starter
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    That was one of the first things I tried. After that I tried HTML elements, and changing the default font for new mail messages (I couldn't find that one from code).
    None of these worked.
    Your example produces a message like this:
    {\rtf1\ansi\ansicpg1252\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss Arial;}{\f3\fswiss MS Sans Serif;}}
    {\colortbl\red0\green0\blue0;\red0\green0\blue255;}
    \deflang1033\pard\plain\f2\fs96\cf1 Hi Aaron!!\plain\f3\fs17
    \par }

    If you have any other ideas, your welcome. Maybe using the MAPI object is an option.

    Thanks anyway

    [This message has been edited by Frans C (edited 11-30-1999).]

Posting Permissions

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



Click Here to Expand Forum to Full Width