How to include formatted text in the body of an Outlook invite from Excel

前端 未结 1 599
死守一世寂寞
死守一世寂寞 2021-01-17 02:01

I would like to insert text with format (links, bold, highlighted...) in an Outlook invite using Excel VBA.

I have a program that send invites from Excel. The body c

1条回答
  •  梦谈多话
    2021-01-17 02:50

    Try this:

    Sub SetApptWithHTMLContent()
    
        Dim olapp As Outlook.Application, appt As Outlook.AppointmentItem
        Dim m As Outlook.MailItem
        Dim rtf() As Byte
    
        Set olapp = New Outlook.Application
        Set m = olapp.CreateItem(olMailItem)
        Set appt = olapp.CreateItem(olAppointmentItem)
    
        appt.Subject = "Meeting request"
        '...set other appointment properties
        appt.Display
        'put the HTML into the mail item, then copy and paste to appt
        m.BodyFormat = olFormatHTML
        m.HTMLBody = Range("A1").Value 'sample HTML stored in a cell
        m.GetInspector().WordEditor.Range.FormattedText.Copy
        appt.GetInspector().WordEditor.Range.FormattedText.Paste
        m.Close False 'don't save...
    
    End Sub
    

    Sample HTML:

      

    Title Here

    Table of stuff:
    One Two
    Three Four

    Final appointment body:

    0 讨论(0)
提交回复
热议问题