Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Sending mail via agent problem - 2 copies of email

Posted on 2002-05-26
15
Medium Priority
?
302 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 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses

885 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