Solved

Sending mail via agent problem - 2 copies of email

Posted on 2002-05-26
15
292 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 

Author Comment

by:HRT_HSV
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
I use the ReplyTo field to make sure replies are sent to the right person :-)
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 10

Expert Comment

by:zvonko
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
:)

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
Comment Utility
thanks i'll give that principal thing a try.
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Thanks for the points :-)

0
 
LVL 9

Expert Comment

by:Arunkumar
Comment Utility
Good Shot Buddy!
0
 
LVL 10

Expert Comment

by:zvonko
Comment Utility
Thanks :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now