|
-
Sep 17th, 2003, 04:10 AM
#1
Thread Starter
Addicted Member
Sending mail using Lotus Notes
Hi
I can send mail using lotus notes and attach files to this mail.
BUT, when I try to add multiple recipients the mail only goes to the first in the list
I'm using the following code to do it
Code:
Public Function SendNotesMail(Recipient As String, Optional Subject As String = "", Optional BodyText As String = "", Optional Attachment As String = "", Optional SaveIt As Boolean = True) As Boolean
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)
On Error GoTo Notes_Err
'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
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = Recipient
MailDoc.Subject = Subject
MailDoc.Body = BodyText
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.send 0, Recipient
SendNotesMail = True
Notes_Resume:
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj = Nothing
Exit Function
Notes_Err:
SendNotesMail = False
GoTo Notes_Resume
End Function
any ideas??
/C
-
Sep 17th, 2003, 04:57 AM
#2
Frenzied Member
Does this help?? I haven't used it, but found it on this forum once.
Multiple Recipients:
VB Code:
Doc.Send(True, strRecipient)
-
Sep 17th, 2003, 05:09 AM
#3
Thread Starter
Addicted Member
thanks
that helped
I turned the 'recipient' string into an array
it now works fine!!
thanks again
/C
-
Sep 17th, 2003, 05:12 AM
#4
Here's what I have...It's crap code and I HATE, HATE, HATE, HATE Lotus notes 
VB Code:
Option Explicit
Private Const SERVER As String = "\\Fil-Notes01/Mail/"
Public Function SendMail(ByVal strRecipients As String, strSubject As String, ByVal strBody As String, ByVal blnSave As Boolean) As Boolean
Dim objSession As Object
Dim objMailDB As Object
Dim objMailDoc As Object
Dim strUsername As String
Dim strMailDBName As String
On Error GoTo Errorhandler
Set objSession = CreateObject("Notes.NotesSession")
strUsername = objSession.Username
If strUsername <> vbNullString Then
strMailDBName = Right(strUsername, Len(strUsername) - InStr(strUsername, "="))
strMailDBName = Left(strMailDBName, InStr(strMailDBName, "/") - 1)
strMailDBName = Mid(strMailDBName, 1, 1) & Right(strMailDBName, Len(strMailDBName) - InStr(strMailDBName, " "))
strMailDBName = strMailDBName & ".nsf"
End If
Set objMailDB = objSession.GETDATABASE(SERVER, strMailDBName)
If Not objMailDB.IsOpen Then
objMailDB.OPENMAIL
End If
Set objMailDoc = objMailDB.CREATEDOCUMENT
With objMailDoc
.Form = "Memo"
.PostedDate = Now()
.SaveOnMessageSend = blnSave
.SendTo = strRecipients
.Subject = strSubject
.Body = strBody
.SEND 0, strRecipients
End With
Errorhandler:
Set objMailDoc = Nothing
Set objMailDB = Nothing
Set objSession = Nothing
If Err.Number <> 0 Then
If Err.Source = App.EXEName Then
Err.Raise Err.Number, "LTRServer - modLotusNotes - SendMail", Err.Description
Else
Err.Raise Err.Number, Err.Source, Err.Description
End If
SendMail = False
Else
SendMail = True
End If
End Function
Public Function ValidEmail(ByVal EmailAddress As String) As Boolean
If Trim$(EmailAddress) <> vbNullString Then
ValidEmail = True
End If
End Function
Notice my great ValidateEmail function 
Sending the same email to many recipients is crap as it won't allow "[email protected], [email protected]"....it gives an error!
STUPID LOTUS NOTES!!!

Woka
-
Sep 17th, 2003, 05:15 AM
#5
I really should read the question properly 
Hey, anyways, I can now send multi-recipients 
Woohohohohohooooo STILL ****************ing hate Lotus Notes!
-
Sep 17th, 2003, 05:32 AM
#6
Frenzied Member
Glad to be of help.
I agree with your sentiments so eloquently expressed
-
Sep 17th, 2003, 06:29 AM
#7
-
Jan 23rd, 2004, 10:18 AM
#8
Hyperactive Member
Help Please
That is great code for Lotus, but being I am completely stupid, how do you turn the string into an array for this to work?
or have you found an easier way?
Thanks,
Susan
Swoozie
Somedays you just should not get out of bed.
-
Jan 23rd, 2004, 10:58 AM
#9
OK use:
VB Code:
Private Function ConvertToArray(ByVal pstrRecipients As String) As String()
Dim strArray() As String
strArray = Split(pstrRecipients, ",")
ConvertToArray = strArray
End Function
This works if you have seperated the email addresses with a comma, if you have used a semi colon then use:
VB Code:
Private Function ConvertToArray(ByVal pstrRecipients As String) As String()
Dim strArray() As String
strArray = Split(pstrRecipients, ";")
ConvertToArray = strArray
End Function
The ";" in the Split function is the character that seperates the email addresses.
Hope that works.
Oh, the Split function is for VB6, not VB5.
I am not using MS Ecxhange and am well happy 
Feel sorry for u using Lotus 
Woof
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|