Receipient address changed to

Posted on 2004-11-18
Last Modified: 2013-12-18

I need your help with a very
difficult problem I encountered with Lotus Notes 5.07a. I'm using the
OLE-Interface to automatically generate and send e-mails from a MS-Access
97 database (no spam of course and just to colleagues). A generated e-mail
should be delivered to several people so I'm constructing a receipient
list, comma separated. After sending the mail, the SENT MAIL folder
contains the e-mail with the receipient list as generated. But only the
first receipient is actually receiving the mail and in this mail one can
see that all the other addresses have been changed to and of course were not delievered. So my question
is: What mechanism is changing the addresses of the 2. to nth receipient
and why and what can I do to prevent this. Any hint will be very much
appreciated. Thank you very much in advance.    Regards    Karl
Question by:cgikb2
    LVL 19

    Expert Comment

    u need to enter person names as


    something like that. I think your receipient list is wrong.

    LVL 46

    Expert Comment

    by:Sjef Bosman
    Could you share some of the code with us, so we can see how you create the addresses and how you call the send-function?

    Other suggestions:
    - could you move from OLE to COM? Notes supports COM quite nicely
    - in COM, the list of recipients should not be comma-separated, but it should be an array of strings, each string being one recipient

    The domain seems to be yours, it points to

    Author Comment

    Tahnk you both for your response

    To madheeswar:
    I'm sorry, I just copied that part of the address that changed. It actually is preceded by a personname of course.

    To sjef_bosman:
    well, changing to COM would mean doing a re-write of the function, so first let's try it with OLE. You asked for the code - here it is:
    Public Function SendNotesMail(Subject As String, Attachment As String, ByVal Recipient As String, ByVal str_CC As String, BodyText As String, SaveIt As Boolean) As String
    'Set up the objects required for Automation into lotus notes
        Dim Maildb As Object 'The mail database
        Dim UserName As String 'The current users notes name
        Dim MailDbName As String 'THe current users notes mail database name
        Dim MailDoc As Object 'The mail document itself
        Dim AttachME As Object 'The attachment richtextfile object
        Dim Session As Object 'The notes session
        Dim EmbedObj As Object 'The embedded object (Attachment)
        Dim Nachricht As String
        Dim Zeichen As Byte
        Dim str_Pfad As String
        Dim I As Integer
        Dim absender As String
        Dim n As Integer
        'Start a session to notes
        Set Session = CreateObject("Notes.NotesSession")
        'Get the sessions username and then calculate the mail file name
        'You may or may not need this as for MailDBname with some systems you
        'can pass an empty string
        UserName = Session.UserName
        MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
        'Open the mail database in notes
        Set Maildb = Session.GetDatabase("", MailDbName)
         If Maildb.IsOpen = True Then
              'Already open for mail
         End If
        absender = Session.CommonUserName
        n = InStr(1, absender, " ")
        If n > 0 Then
           absender = Mid$(absender, n + 1, Len(absender))
        End If
        'Set up the new mail document
        Set MailDoc = Maildb.CreateDocument
        MailDoc.Form = "Memo"
        MailDoc.sendto = Recipient
        MailDoc.copyto = str_CC
        MailDoc.Subject = Subject
        Open BodyText For Binary As #1
        While Not EOF(1)
           Get #1, , Zeichen
           Nachricht = Nachricht + Chr(Zeichen)
        Close #1
        Nachricht = Left$(Nachricht, Len(Nachricht) - 1)
        str_Pfad = ActiveWorkbook.FullName
        I = Len(str_Pfad)
        While Mid$(str_Pfad, I, 1) <> "\"
           I = I - 1
        str_Pfad = Left$(str_Pfad, I)
        Open str_Pfad + "MailFooter.txt" For Binary As #1
           While Not EOF(1)
           Get #1, , Zeichen
           Nachricht = Nachricht + Chr(Zeichen)
        Close #1

        MailDoc.body = Nachricht
        MailDoc.SaveMessageOnSend = SaveIt
        'Set up the embedded object and attachment and attach it
        If Attachment <> "" Then
            Set AttachME = MailDoc.CreateRichTextItem("Attachment")
            Set EmbedObj = AttachME.EmbedObject(1454, "", Attachment, "Attachment")
            MailDoc.CreateRichTextItem ("Attachment")
        End If
        'Send the document
        MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
        MailDoc.Send 0, Recipient
        'Clean Up
        Set Maildb = Nothing
        Set MailDoc = Nothing
        Set AttachME = Nothing
        Set Session = Nothing
        Set EmbedObj = Nothing
        SendNotesMail = absender
    End Function

    I tried your suggestion with the array but it failed in an interessting way: The document in the SENT MAIL folder had no recipients and the recipient got a mail with the original error.

    I made the following assignment:

    MailDoc.sendto = Recipient_1

    where Recipient_1 was defined as array of strings. Or should I use the address-operator & in this case ?
    LVL 46

    Assisted Solution

    by:Sjef Bosman
    Recipient_1 should be an array of strings, probably something like this (my VBA is a bit rusty..):

        Dim Recipient_1(2) As String

        Recipient_1(0)= "Tom Doe/Org"
        Recipient_1(1)= "Dick Doe/Org"
        Recipient_1(2)= "Harry Doe/Org"
        maildoc.sendto= Recipient_1

        mailDoc.send 0 ' 2nd parameter not required
    LVL 24

    Accepted Solution

    Your problem as mentioned by SJEF is occuring due to the fact that "ByVal Recipient As String" ... passing the recipeint list as one complete string...

    In that case.. notes takes the name value upto the first comma seperator and ignore or fail in conversion.

    The answer to your question is pass the recipient value as array.

    BTW, Do you work for DaimlerChrylser ?


    Author Comment

    To sjef_bosman and HemanthaKumar:
    I just tried it out and only the first recipient received the massage. One improvement I got: No address was changed. I tried it with Internet-style- and Lotus-style addresses. So I assume using an array is one right step. The only missing step is how to tell Lotus how many recipients there are - any ideas ?

    Thanks for yoour good support
    LVL 24

    Expert Comment

    Use Ubound for array count
    LVL 46

    Expert Comment

    by:Sjef Bosman
    You need to create as many entries in the array as there are recipients, e.g. use Redim Preserve for that purpose. Or if there is a VB-function that will split a string on a certain symbol (the comma) into an array of strings (like in JavaScript), then use that one.

    Massage? Ist das freudianisch? ;)

    Author Comment

    To sjef_bosman and HemanthaKumar:

    Thank you very much both of you. The code is now running with this array method. I just overlooked one detail: The MailDoc.Send instruction still passed the original Recipient variable instead of the new Recipient_1 Array-variable.

    Keep up the good work and thanks again.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    This is an old article, please see an updated version of this article, located here:
    This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now