lotus notes and vb

I can email with attachment fine, but i need to send to multiple addresses. I dont know how to do this. If i comma seperate the addresses the second address gets corrupted somehow. Does anyone have any fast code on emailing to multiple addresses?
LVL 2
damion69Asked:
Who is Participating?
 
dkaygeeConnect With a Mentor Commented:
Try this out: Essentially, you have to set up an array of users that you want to email.

Dim CntRecipients(1 To 3) As String
  CntRecipients(1) = "User 1@whatever.com"
  CntRecipients(2) = "User 2@whatever.com"
  CntRecipients(3) = "User 3@@whatever.com"
 
  Set Session = CreateObject("Notes.NotesSession")
 
  strUserName = Session.UserName
  Set db = Session.GETDATABASE("", "")

  If db.ISOPEN = True Then
  'Do nothing, mail is already open
  Else
 
  Call db.OPENMAIL
  End If
 
  Set doc = db.CREATEDOCUMENT()
  doc.Form = "Memo"
  doc.Subject = strSubject & " # " & strRequestNumber
  doc.Body = strBodyText
  doc.CopyTo = strCC
  'Blind Copies the User
  doc.BlindCopyTo = strUserName

  Call doc.SEND(False, CntRecipients)
 
  'Unload from memory
  Set Session = Nothing
  Set db = Nothing
  Set doc = Nothing

I also have created a Class module that essentially works
the same way:


Public Sub SendLotusNotesEMail(strBodyText As String, strSubject As String, _
                                strRecipients() As String, strCC As String)
  On Error GoTo Err

  Dim Session As Object
  'Dim Session As NOTESSESSION
  Dim db As Object
  'Dim db As NOTESDATABASE
  Dim doc As Object
  'Dim doc As notesdocument
  Dim strUserName As String
  Dim MailDbName As String
  Dim Test
 
  Set Session = CreateObject("Notes.NotesSession")
 'This Code will fail if Lotus Notes is open and the user is NOT logged in.
 'Error Message provided.
 
  strUserName = Session.UserName
 
  'Using Default Server,Database
  Set db = Session.GETDATABASE("", "")

  If db.ISOPEN = True Then
  'Do nothing, mail is already open
  Else
 
 
  Call db.OPENMAIL
  End If
 
  Set doc = db.CREATEDOCUMENT()
  doc.Form = "Memo"
  doc.Subject = strSubject
  doc.Body = strBodyText
  doc.CopyTo = strCC
  'Blind Copies the User
  doc.BlindCopyTo = strUserName
 
  'Call doc.Send(AttachForm(true/false),Recipients array)
  Call doc.SEND(False, strRecipients)
   
    'Unload from memory
    Set doc = Nothing
    Set Session = Nothing
    Set db = Nothing
Exit Sub
Err:
Select Case Err.Number
    Case 7063
    MsgBox "User Not Logged Into Lotus Notes", vbCritical
    MsgBox "Email Attempt Failed"
    Set doc = Nothing
    Set Session = Nothing
    Set db = Nothing
    Exit Sub
    Case Else
    Err.Raise vbObjectError + 1000, , "Lotus Notes Email Error"
End Select

End Sub

0
 
damion69Author Commented:
Thank you i have been toying around with this for way to long.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.