jeudi 9 août 2018

How to compose email in office 365 outlook using VBA?

I am able to compose email in Desktop Microsoft outlook using the below mentioned code. But this code is not working for Microsoft office 365 web outlook. Please provide me Code/Suggestion for composing mail in Microsoft office 365 web outlook.

Sub Mail_small_Text_Outlook()
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

strbody = "Hi there" & vbNewLine & vbNewLine & _
          "This is line 1" & vbNewLine & _
          "This is line 2" & vbNewLine & _
          "This is line 3" & vbNewLine & _
          "This is line 4"

On Error Resume Next
With OutMail
    .To = "ron@debruin.nl"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = strbody
    'You can add a file like this
    '.Attachments.Add ("C:\test.txt")
    .Send   'or use .Display
End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub




Aucun commentaire:

Enregistrer un commentaire