HTML mail created by LS agent : does sb know THE solution?

Hi !

I’ve tried to code an agent to send HTML mails to my customers. But I haven’t found a solution which works for all providers. For example, I had to suppress every chr(13) in the body to see the mails accepted by some providers (free.fr for example) but other providers (banquespopulaires.fr) couldn’t accept the mails because of the length of the line…

So, is there someone who could share a solution ? Here is the function I’ve coded to generate the mail directly in the mail.box :


Function SendHTMLMail(subject As String, body As String, recipients As String, whofrom As String , emailtoreplyto As String)

If (Trim(recipients)<>"") Then

	

	Dim s As New NotesSession

	Dim doctosend As NotesDocument

	Dim stream As NotesStream

	Dim bodyHTML As NotesMIMEEntity

	Dim child As NotesMIMEEntity

	Dim mailbox As New NotesDatabase("","mail.box")

	

	Set doctosend = mailbox.CreateDocument

	doctosend.Form="Memo"

	

	s.ConvertMIME = False ' Do not convert MIME to rich text

	Set stream = s.CreateStream

	Set bodyHTML = doctosend.CreateMIMEEntity

	Set header = bodyHTML.CreateHeader("From")

	Call header.SetHeaderVal(whofrom)

	Set header = bodyHTML.CreateHeader("SMTPOriginator")

	Call header.SetHeaderVal(whofrom)

	Set header = bodyHTML.CreateHeader("Sender")

	Call header.SetHeaderVal(whofrom)

	If emailtoreplyto<>"" Then

		Set header = bodyHTML.CreateHeader("ReplyTo")

		Call header.SetHeaderVal(emailtoreplyto)

	End If

’ body=Replace(body,Chr(13),“”)

’ body=Replace(body,Chr(10),“”)

	Set child=bodyHTML.CreateChildEntity

	Call stream.WriteText(body)

	Call child.SetContentFromText(stream,"text/html;charset=ISO-8859-1",ENC_NONE)

	Call stream.Truncate

	

	Call doctosend.ReplaceItemValue("Subject",subject)

	

	Dim recip As New NotesItem(doctosend,"Recipients",recipients,NAMES)

	Dim sendTo As New NotesItem(doctosend,"SendTo",recipients,NAMES)

	recip.IsSummary=True

	sendTo.IsSummary=True

	Call doctosend.ReplaceItemValue("PostedDate",Now)

	

	Call doctosend.Save(False,False)

	s.ConvertMIME = True ' Restore conversion

	

End If

End Function


Note that I haven’t used the document.send method because it created some other problems (I had to change the “Run on behalf of” parameter for the mail address of the sender to see the mails accepted by some providers).

Thanks for your help !


Ralph Sicabol

Subject: HTML mail created by LS agent : does sb know THE solution ?

I am not going to address the main issue because there are just too many variables you cannot control.

What I am going to address is customer privacy. By sending the mail the way you are, you are listing all of your customers’ email addresses in the “To” field. This violates their privacy by letting others know that they are one of your customers and also puts your own business at risk by exposing your customer list.

You should either:

  1. Put the recipients in the Blind Copy field and mail the document to yourself or a generic ID.; or

  2. Rewrite this subroutine to send out individual emails. I would recommend this approach because then you can personalize the mail and give the customers a warm fuzzy feeling.

Subject: RE: HTML mail created by LS agent : does sb know THE solution ?

Of course I don’t put all the mail addresses in the “To” field! This is a function, I launch it for every customer :wink:

But I’ve manage to write a good code now, thanks !

Subject: HTML mail created by LS agent : does sb know THE solution ?

you may want to consider creating the email with just the Body field being a mime entity, not the whole thing, ie leave all the other fields as normal notes fields and not mime headers. you’ll find that the router will convert them as required.