Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011

    Unanswered: [Resolved]VBA to Send Email from Group Email Box via Lotus Notes

    Good Afternoon,
    I am trying to send a email with attachment from a group email box to a certian invidual. The group email and the Send To email are defined on a table but are partly hard coded for testing at this point.

    With the code below I can have it send the email from my email box just fine but not from a diffrent email box which I have manager access to. I am stumped I also looked ant lotus support and no luck there. It looks right to me but might be way off.

    The first section tests if a codition is meet if so it calls the email lable and builds the email parts. then sends to the public function to actually do the email build and send. We do this because the email section gets used in multiple places in the system and we do not want redundancy.

    Any help would be great.


    Start up form(always opens)

    Public Sub EmailReferral()
    Dim INTcountRTF As Integer
    Dim INTcountCOA As Integer
    Dim MyPathRTF As String
    Dim MyPathCOA As String
    Dim MyFileNameRTF As String
    Dim MyFileNameCOA As String
    Dim stTo As String
    Dim stCc As String
    Dim stMsg As String
    Dim stSubject As String
    Dim stAtt As String
    Dim MailName As String

    INTcountRTF = DCount("[INTRNL_ID]", "STSEG_TSTSEGNC", "[FLW_UP_ACT] = 31")
    MyPathRTF = "H:\"
    MyFileNameRTF = "Referred to Field as of " & Format(Date, "mm-dd-yyyy") & ".pdf"

    If INTcountRTF >= 5 Then
    DoCmd.OutputTo acOutputReport, "rptRTF", acFormatPDF, MyPathRTF & MyFileNameRTF, False

    MailName = "databases\mail\STSAReferrals.nsf"

    stMsg = "Test"
    stMsg = stMsg + "As this program remains as a high priority for the Department, can you please request field visits be completed within next 2 to 3 weeks?"
    stMsg = stMsg + Chr(10) + Chr(10) + "Auto-Generated By STSA Tracking System"

    stTo = "t55834"

    stSubject = "STSA Assistance Requested"

    stAtt = "h:\" & Format(Date, "mm-dd-yyyy") & ".pdf"

    sendEmail stMsg, stSubject, stCc, stTo, stAtt, MailName
    End If

    End Sub


    Email function:

    Public Function sendEmail(stMsg As String, stSubject As String, stCc As String, stTo As String, stAtt As String, MailName As String)

    Dim s As Object
    Dim db As Object
    Dim doc As Object
    Dim EMBEDOBJ As Object
    Dim AttachMe As Object
    Dim Maildb As Object
    Dim Session As Object

    Set s = CreateObject("Notes.Notessession") 'creates notes session
    If MailName <> "" Then

    Set db = s.GetDatabase("", "")
    Call db.openmail("ALBAPP01", MailName)
    Set db = s.GetDatabase("", "") 'set db to database not yet named
    Call db.openmail 'set database to default mail database
    End If

    Set doc = db.CreateDocument ' create a mail doc
    If stAtt <> "" Then
    Set AttachMe = doc.CREATERICHTEXTITEM("Attachment")
    Set EMBEDOBJ = AttachMe.EMBEDOBJECT(1454, "", stAtt)

    End If
    Call doc.ReplaceItemValue("SendTo", stTo) 'send to
    Call doc.ReplaceItemValue("Subject", stSubject)
    Call doc.ReplaceItemValue("Body", stMsg)
    Call doc.ReplaceItemValue("CopyTo", stCc)
    Call doc.ReplaceItemValue("Importance", "1") 'set importance flag
    Call doc.ReplaceItemValue("ReturnReceipt", "1") 'Receipt Flag

    Call doc.send(False) 'send the message
    MsgBox doc.GetItemValue("Body")(0)
    Set s = Nothing ' close connection to free memory

    End Function
    Last edited by jblanch8; 06-06-12 at 16:09.

  2. #2
    Join Date
    Nov 2011
    It was a simple line prior to the Send method.
    doc.principal = "Email Address you want it from"

Tags for this Thread

Posting Permissions

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