Solved

lotus notes and vb

Posted on 2001-06-06
2
215 Views
Last Modified: 2010-05-02
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?
0
Comment
Question by:damion69
2 Comments
 
LVL 1

Accepted Solution

by:
dkaygee earned 50 total points
ID: 6160397
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
 
LVL 2

Author Comment

by:damion69
ID: 6160469
Thank you i have been toying around with this for way to long.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 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