+ Reply to Thread
Results 1 to 4 of 4

VBA Send email from outlook 2016

  1. #1
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    203

    VBA Send email from outlook 2016

    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

  2. #2
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    Office 365 ProPlus
    Posts
    5,881

    Re: VBA Send email from outlook 2016

    Lotus and Outlook is different program and you'd need to use different object model.

    For email code using Outlook refer to Ron de Bruin's site. It's one of best resources out there for it.
    https://www.rondebruin.nl/win/s1/outlook/mail.htm
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: VBA Send email from outlook 2016

    @kirana2014

    please use codetags around the code, according to the forumrules.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    203

    Re: VBA Send email from outlook 2016

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA auto outlook 2016 to send e-mail based off criteria
    By broman5000 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-30-2017, 04:15 PM
  2. Send email from shared Outlook email address
    By rousseauassociates in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-27-2016, 07:33 AM
  3. Send an email via outlook from and address other than your default email.
    By sungen99 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-28-2015, 06:15 PM
  4. Email Macro o send Outlook Email
    By asivaprakash in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-01-2013, 07:05 PM
  5. send selected range in email with default outlook email signature included
    By mdsickler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2013, 10:50 PM
  6. Send email via outlook
    By sakmsb in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-29-2013, 11:14 PM
  7. Send Email from outlook
    By wawansur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-20-2010, 04:09 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1