More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 18-Jan-2017 06:51

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 ]  
 Outlook and .NET Printer Friendly Version
Writing code with C# and VB.NET to create Outlook add-ins and other projects
Appointment Item with HTML body - Outlook 2007 and 2010

I tried Sue's method of using the inspector and wordeditor to put HTML text into a word document but I cant seem to get it to work.

I can send the appointment no problem but there is no text at all. I used the macro recorder to get the selection code.

        Dim objolApp4 As New Microsoft.Office.Interop.Outlook.Application
            Dim objNS4 As Microsoft.Office.Interop.Outlook.NameSpace
            Dim objRecip4 As Microsoft.Office.Interop.Outlook.Recipient
            Dim objFolder4 As Microsoft.Office.Interop.Outlook.MAPIFolder
            Dim objAppt4 As Microsoft.Office.Interop.Outlook.AppointmentItem

            objNS4 = objolApp4.GetNamespace("MAPI")
            objRecip4 = objNS4.CreateRecipient("username")
            objFolder4 = objNS4.GetSharedDefaultFolder(objRecip4, Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar)

            objAppt4 = objFolder4.Items.Add

            If objAppt4.Recipients.Add("username").Resolve() = True Then

                Dim myInspector1 As Microsoft.Office.Interop.Outlook.Inspector
                myInspector1 = objAppt4.GetInspector

                Dim objDoc As Microsoft.Office.Interop.Word.Document
                Dim objSel As Microsoft.Office.Interop.Word.Selection

                objDoc = myInspector1.WordEditor
                objSel = objDoc.Windows(1).Selection

                objSel.TypeText(Text:="This is a new appointment")
                objSel.TypeText(Text:="Password: TEST12someone")
                objSel.MoveDown(Unit:=WdUnits.wdLine, Count:=1, Extend:=WdMovementType.wdExtend)
                objSel.MoveLeft(Unit:=WdUnits.wdCharacter, Count:=11, Extend:=WdMovementType.wdExtend)
                objSel.MoveRight(Unit:=WdUnits.wdCharacter, Count:=1, Extend:=WdMovementType.wdExtend)
                objSel.Font.Bold = WdConstants.wdToggle
                objSel.Font.Color = WdColor.wdColorRed

                objAppt4.MeetingStatus = Microsoft.Office.Interop.Outlook.OlMeetingStatus.olMeeting
                Dim DODwipedate As Date = date2.AddDays(7)

                objAppt4.Start = Convert.ToDateTime(DODwipedate & " " & "8:00:00am")
                objAppt4.Duration = 30
                objAppt4.Subject = "IGNORE : MUAHAHAHAHAHAHA!!!!"


                System.Windows.Forms.MessageBox.Show("The username of the user is wrong. Please check.")

  19-Nov-2012  17:22
    Page [ 1 ]