[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

VBA code to format an Outlook TaskItem BODY

Asked by darbid73 in Access Coding/Macros, Outlook Groupware Software, Microsoft Word

Tags: Outlook 2003, TaskItem, RTFeditor

I want to format the body of a taskitem.

I am restricted as the editortype of inspector is olEditorRTF.  I think these means I cannot use Word from within Outlook to format the body.

Could someone please show me the code I need to use.

Below is my general function to add a taskitem.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
Private Function addOutlookTask(dt_startdate As Date, _
                                dt_enddate As Date, _
                                str_body As String, _
                                str_mileage As String, _
                                str_subject As String) As Boolean 

Dim olApp As Outlook.Application
Dim oTask As TaskItem
Dim bln_QuitOutlook As Boolean 'if outlook is not open then set this to true and close outlook at the end
Dim dt_remindertime As String 
On Error GoTo ErrorHandler 
Set olApp = GetObject(, "Outlook.Application") 
 
Set oTask = olApp.CreateItem(olTaskItem) 
With oTask
    .StartDate = Format(dt_startdate, "Short Date") & " " & Format("9.00", "Short Time")
    .DueDate = Format(dt_enddate, "Short Date") & " " & Format("17.00", "Short Time")
    .Status = olTaskInProgress
    
    If DateDiff("d", .StartDate, .DueDate) > 5 Then
        dt_remindertime = Format((DateAdd("d", (Int(0.75 * DateDiff("d", .StartDate, .DueDate))), .StartDate)), "Short Date") & _
        " " & Format("9.00", "Short Time")
                
        Select Case Weekday(dt_remindertime, vbMonday)
        
            Case 6
                dt_remindertime = DateAdd("d", -1, dt_remindertime)
            Case 7
                dt_remindertime = DateAdd("d", -2, dt_remindertime)
        End Select
    Else
        dt_remindertime = DateAdd("d", -2, .DueDate)
    End If
    .Mileage = str_mileage
    .ReminderSet = True
    .ReminderTime = dt_remindertime
    .Subject = str_subject
    .body = str_body
    .Save 
End With 
 
Set oTask = Nothing 
If bln_QuitOutlook Then
    olApp.Quit
End If 
Set olApp = Nothing 

addOutlookTask = True 

ErrorHandlerExit:
   Set oTask = Nothing
   Set olApp = Nothing
   Exit Function 
ErrorHandler:
   'Outlook is not running; open Outlook with CreateObject
   If Err.Number = 429 Then
      Set olApp = CreateObject("Outlook.Application")
     bln_QuitOutlook = True
      Resume Next
   Else
      MsgBox "Error No: " & Err.Number _
         & "; Description: " & Err.Description
      Resume ErrorHandlerExit
   End If
End Function
 
Related Solutions
Keywords: VBA code to format an Outlook TaskIte…
 
Loading Advertisement...
 
[+][-]11/04/09 04:25 AM, ID: 25738588Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 04:46 AM, ID: 25738718Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 04:51 AM, ID: 25738750Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 05:58 AM, ID: 25739318Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 07:58 AM, ID: 25740614Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 11:13 AM, ID: 25742765Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/04/09 11:51 AM, ID: 25743176Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/04/09 12:00 PM, ID: 25743293Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625