New line in Outlook task

155 views Asked by At

I have to create Outlook Task from Access. All works fine but I cannot figure out how to create a new line in Body. This is my code:

Public Function AddOlTask(sSubject As String, sBody As String, _
                    dtDueDate As Date, dtReminderDate As Date)

    Const olTaskItem = 3
    Dim OlApp As Object
    Dim OlTask As Object

    Set OlApp = CreateObject("Outlook.Application")
    Set OlTask = OlApp.CreateItem(olTaskItem)

    With OlTask
        .Subject = sSubject
        .DueDate = dtDueDate
        .Status = 3   
        .Importance = 1     
        .ReminderSet = True
        .ReminderTime = dtReminderDate
        .categories = "Business" 
        .Body = sBody
        .Save   
    End With
End Function

I tried to use <br/>, vbCrLf. I tried to assign it similar to Message to property like .HTMLBody = sBody (incorrect property). Used .RTFBody = -1. Nothing works. Any suggestion?

1

There are 1 answers

4
Vlado On

I got it. The string has to be written like this:

"SuborderID: " & Me.SuborderID & vbNewLine & vbCr & "PO Date: " & txtETAonPO

It creates this message: SuborderID: 62075 PO Date: 3/12/2020