Solved

Sending mail via agent problem - 2 copies of email

Posted on 2002-05-26
15
295 Views
Last Modified: 2013-12-18
Hi All,
I have created an agent that sends out a customised email to people registered on a web site. I use code i have used in other agents that do the same thing and they work perfectly, this one though is a bit different in that it doesn't send a single email like the others, instead it loops through a list of all web site members registered to receive the email and sends out a customises email to them. However some people get two copies of this email, one in their inbox and another in their "draft" folder, this ONLY happens to Lotus users, people with other email clients do not get this extra email.

Anyone have any ideas on how i can fix this?



0
Comment
Question by:HRT_HSV
  • 7
  • 4
  • 3
  • +1
15 Comments
 
LVL 10

Expert Comment

by:zvonko
ID: 7036507
Look for this mails arriving into Draft view by accident.
Compare their document item values with the Draft view selection formula.
The regular Draft view selection formula is:
SELECT PostedDate = "" & $MessageType = "" & @IsNotMember("D";ExcludeFromView) & ISMAILSTATIONERY != 1 & Form != "Person"

That means, either is PostedDate and $MessageType empty in your mails, or somebody changed the view selection formula in your installation to something else.

Good luck,
zvonko

0
 

Author Comment

by:HRT_HSV
ID: 7036539
Thanks zvonko
How can i make sure that PostedDate and $MessageType are not empty?

Can i actually specify their values at the time i am creating the mails?

This is part of my code with error checking taken out, like i said it all works except for the draft copy thing. What do i do to fix the problem?:

Function testmail(_
sendTo As String, _
cc As String, _
bcc As String, _
subject As String, _
body As String, server As String) As String

Dim mailboxDb As New NotesDatabase(server, "mail.box")
     Dim mailDoc As NotesDocument
     Dim rtItem As NotesRichTextItem
     
     Set mailDoc = mailboxDb.CreateDocument
     mailDoc.Form = "Memo"
     mailDoc.From = "sender@anysite.com"
     mailDoc.SendTo = sendTo
     mailDoc.Recipients = sendTo
     mailDoc.CC = cc
     mailDoc.BCC = bcc
     mailDoc.Subject = subject
     Set rtItem = mailDoc.CreateRichTextItem("Body")
     Call rtItem.AppendText(body)
     If strAttach <> "none" Then
          rtItem.EmbedObject EMBED_ATTACHMENT,"",strAttach          
     End If
     
     Call mailDoc.Save(True,False,False)
End Function

0
 
LVL 10

Accepted Solution

by:
zvonko earned 100 total points
ID: 7036623
You make jokes :-)

This is an absolutely unclean method to get mails sent!

Normal way is to create a document object in the database your agent is actually running and use this NotesDocument method afterwards:
Call doc.Send(True)

And only if you like a mail copy stay saved in this database where you initiated the male use the doc.Save() method.

In your function you have to exchange this line:
Dim mailboxDb As New NotesDatabase(server, "mail.box")

to something like this:
Dim session As New NotesSession
Dim mailboxDb As NotesDatabase
Set mailboxDb = session.CurrentDatabase

and the Save line like this:
Call mailDoc.Send(True)

Good luck,
zvonko

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:HRT_HSV
ID: 7038198
oh ok, thanks for the info, new to this.

But will this work even if my Agent is not in the mail box database?

I thought to send mail you have to use the memo form? If this agent is not in the mail box database then the memo form isn't available to me and the line:
 mailDoc.Form = "Memo"

will produce an error won't it?

So the rest of the code will continue to work fine if i just change the lines you mention? Allowing me to customise who it is from,subject etc?

thanks again
0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7038443
Yes, you can send mail from anywhere. The memo form doesn't need to be available.
You can create a custom mail form if you want to use a standard layout for automated mails (I do this, to make it clear to users that this is an automated mail they should not respond to).

The send method has the following parameters syntax:

Call notesDocument.Send( attachForm [, recipients ] )

If you specify True for attachForm, the form you use to create the mail will be sent along with the mail, otherwise the default memo form is used.
If you do not specify recipients in SendTo field, you can specify an array of recipients as a second parameter.

Hope this helps,
JM
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7038705
The only feature that will not work is the From field :-)

And this was the only reason for this unclean method to be used.

Instead of From you can use a surrogate field: Principal

The Memo form is in everyone's mail database as default form. That mean you need not to declare the Form item.

But when you set the first parameter of NotesDocument.Send method to True then you have to declare a form name in the Form field and have to have the declared Form existing in used database. It has to be there to be embedded.

Regards,
zvonko

0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7039015
I use the ReplyTo field to make sure replies are sent to the right person :-)
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7039106
That's correct JM, but most programmer like to avoid to be visible/responsible as agent signer for mail sending. And this is only possible with mail.box method or with Principal field. They are still contained in sender field but Principal get visible sender content.

0
 
LVL 8

Expert Comment

by:Jean Marie Geeraerts
ID: 7039126
ReplyTo is never the programmer. It's always a responsible contact person, so it can be visible :-)
So, if you put the name to respond to in 'Principal' you can respond, but you don't see to who you respond?
0
 

Author Comment

by:HRT_HSV
ID: 7040792
I tried adding the following code to the database:

maildoc.Principal = "xxxxxx"
maildoc.ReplyTo = "me@whereva.com"

and the reply to works but i still get a sent by:"name of agent signer" withing the message header.

wasn't the Principal field meant to fix this problem?


As zvonko stated this 'unclean' method was used for that purpose. There must be a way to get rid of this problem using the clean method, after all one would think it is a basic functionality that all automated email processing functions should have.

great help so far by the way guys.


0
 
LVL 10

Expert Comment

by:zvonko
ID: 7040807
:)

This Principal is a little tricky.

Try this:
maildoc.Principal = "NotesCommonName@NotesDomain"

or this:
maildoc.Principal = "internetEmail@InternetDomain@NotesDomain"

In both cases is best choice to use a mailin database address.

Good luck,
zvonko



0
 

Author Comment

by:HRT_HSV
ID: 7040920
thanks i'll give that principal thing a try.
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7041035
Thanks for the points :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
ID: 7041438
Good Shot Buddy!
0
 
LVL 10

Expert Comment

by:zvonko
ID: 7041580
Thanks :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
For beginners of Lotus Notes user this is important to know about the types of files and their location supported by IBM Notes. Mostly users are unaware about how many file types are created and what their usages are. This Article is fully dedicated…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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