Results 1 to 3 of 3

Thread: [RESOLVED] [2.0] Formatting Autogenerated Emails

  1. #1

    Thread Starter
    Hyperactive Member Quasar6's Avatar
    Join Date
    Mar 2008
    Location
    Sol 3
    Posts
    325

    Resolved [RESOLVED] [2.0] Formatting Autogenerated Emails

    I'm not entirely sure if this should go in the C# or Office Dev forums, but here goes anyway:

    I'm autogenerating an email from data contained within my program using the Outlook Interop Namespace (9.3.0.0).

    Code:
    Outlook.Application moApp = new Outlook.Application();
    
                        Outlook.MailItem oEmail = (Outlook.MailItem)moApp.CreateItem(Outlook.OlItemType.olMailItem);
                        oEmail.Subject = "Project " + ProjectName + "- Reference # " + dlog.RefNum.Text + " - " + Ref_Description.Text;
                        oEmail.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
                        oEmail.Body = @"Refer to images " + Ref_Imgs.Text + @"
    
    " + Ref_FullBodyDescription.Text + @"
    
    
    
    PRIORITY: " + dlog.priority.Text + @"
    
    Regards,
    " + userName + @"
    " + companyName;
    This is OK, but a little plain: I would like to add some formatting: Italics on "Refer to images", Bold on "Priority", etc. I've had a few quick attempts with .olFormatHTML and .olFormatRichText, but with no luck. Any help would be appreciated. Thanks!

    C# Express, 2005.
    "Why do all my attempts at science end with me getting punched by batman?" xkcd.

    |Pong||
    Sorry for not posting more often.

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: [2.0] Formatting Autogenerated Emails

    When it comes to emails, there should be an IsBodyHTML property to the mail object itself. Set that to true, then just use standard HTML formatting codes. <b></b> to bold, <i></i> to italic, and so on and so forth.

  3. #3

    Thread Starter
    Hyperactive Member Quasar6's Avatar
    Join Date
    Mar 2008
    Location
    Sol 3
    Posts
    325

    Re: [2.0] Formatting Autogenerated Emails

    Awesome. It was a little more complicated than that: (I had to change the BodyHTML string property to a complete HTML format) but it works. Thanks for your help.
    "Why do all my attempts at science end with me getting punched by batman?" xkcd.

    |Pong||
    Sorry for not posting more often.

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