cgikb2
asked on
Receipient address changed to @wkldoinall.wk.dcx.com
Hello,
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
@wkldoinall.wk.dcx.com 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
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
@wkldoinall.wk.dcx.com 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
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 ns1.sns-felb.debis.de
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 ns1.sns-felb.debis.de
ASKER
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.NotesS ession")
'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
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)
Wend
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
Wend
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)
Wend
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 ("Attachme nt")
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 ?
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.NotesS
'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
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)
Wend
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
Wend
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)
Wend
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
Set EmbedObj = AttachME.EmbedObject(1454,
MailDoc.CreateRichTextItem
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 ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
Use Ubound for array count
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? ;)
Massage? Ist das freudianisch? ;)
ASKER
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.
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.
Ex: maddy@yahoo.com, maddy1@abc.com
something like that. I think your receipient list is wrong.