Dear mr/mrs,
Below VBA is working on Lotus notes,
can somebody help me to edit below VBA that I can Use them on outlook 2016
thank you in advance for your support
Dim EMail As String
EMail1 = Sheets("Email").Range("A2").Value
EMail2 = Sheets("Email").Range("B2").Value
EMail3 = Sheets("Email").Range("C2").Value
Dim oSess As Object
Dim oDB As Object
Dim oDoc As Object
Dim oItem As Object
Dim direct As Object
Dim Var As Variant
Dim flag As Boolean
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = "P details"
oDoc.sendto = EMail1
oDoc.copyto = EMail2
oDoc.blindcopyto = EMail3
oDoc.body = "Dear mr/mrs," & String$(2, vbCrLf) & "We here by inform you ………..” & vbCrLf & "See attachment…….” & String$(4, vbCrLf) & "Met vriendelijke groet/With kind Regards," & vbCrLf & "TEST B.V." & String$(4, vbCrLf) & "MR TEST" & vbCrLf & "Account Departemen"
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
With Sheets("Vendor")
stPath = "C:\Payment details\"
stPath = stPath & "Payment " & .Range("J6").Value & "\"
With CreateObject("Scripting.FileSystemObject")
If Not .FolderExists(stPath) Then .CreateFolder stPath
End With
Call oItem.EmbedObject(1454, "", stPath & "\Details 1234.xls")
oDoc.visable = True
'Pengiriman pesan
oDoc.SEND False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
'Selesai
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End With
End Sub
Bookmarks