Help! Lotus Mail from VBA (How to choose from which user id to send mail?)

Vishesh's picture

One of my clients have two mail ids configured on his/her lotus notes? Every time a mail is sent it is sent using the default id. The other id is group id that he wants to use for sending mails from vba (without making it the default id). The code that we are using is this...I want to know how to set the sender mail id in Lotus Notes from vba...

Following is the stardardised code to send mail from Lotus...

 

Public Function SendEmail(strMailTo As String, strSubject As String,  _
  strBodyText As String, blnReceipt As Boolean, Optional strAttachment As _
   String, Optional strCCTo As String, Optional strBCCTo As String) As Long
 
'This will return 0 if successfull else error number
    Dim objApp                  As Object
    Dim objMail                 As Object
    Dim objLotusDB              As Object
    Dim objLotusItem            As Object
    Dim arrAttachment()         As String
    Dim strLotusUser            As String
    Dim strLotusDbName          As String
    Dim intAttachLoop           As Integer
 
    DoEvents
 
    On Error GoTo ErrHandler
    Set objApp = CreateObject("Notes.NotesSession")
 
    strLotusUser = objApp.UserName
    strLotusDbName = Left$(strLotusUser, 1) & Right$(strLotusUser, (Len _
     (strLotusUser) - InStr(1, strLotusUser, " "))) & ".nsf"
 
    Set objLotusDB = objApp.GETDATABASE("", strLotusDbName)
 
    If Not objLotusDB.IsOpen Then
        objLotusDB.OPENMAIL
    End If
 
    Set objMail = objLotusDB.CREATEDOCUMENT
    Set objLotusItem = objMail.CREATERICHTEXTITEM("BODY")
 
    With objMail
        .Form = "Memo"
        .sendTo = split(strMailTo, ",")
        If Len(strCCTo) > 0 Then .CopyTo = split(strCCTo, ",")
        If Len(strBCCTo) > 0 Then .BlindCopyTo = split(strBCCTo, ",")
        .Subject = strSubject
        .Body = strBodyText
        .posteddate = Now()
        If blnReceipt Then .ReturnReceipt = "1"
        .SaveMessageOnSend = True
 
        'Attachments
        If Len(strAttachment) > 0 Then
            arrAttachment() = split(strAttachment, ",")
            For intAttachLoop = 0 To UBound(arrAttachment, 1)
                Call objLotusItem.EmbedObject(1454, vbNullString, _
                    arrAttachment(intAttachLoop), "")
            Next intAttachLoop
        End If
 
        .Visible = True
        .Send False
    End With
 
    SendEmail = 0 'Success returned
    
exitSendAttachment:
    Set objLotusDB = Nothing
    Set objLotusItem = Nothing
    Set objApp = Nothing
    Set objMail = Nothing
    Exit Function
 
ErrHandler:
    SendEmail = Err.Number 'Error returned
    GoTo exitSendAttachment
 
End Function

Same Problem

Did u find the workaround. I happen to have the same problem

JPH's picture

Don't have the Answer only more questions

Hello hivishy,

Don't have the answer for you but maybe these questions can help.

Is there a second database for the second ID?

If so, is there a way to open that one and go from there?

It's not much, i know