PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Multiple recipients - Outlook
Multiple recipients - Outlook
Débuté par Norman, 30 mar. 2017 10:35 - 2 réponses
Posté le 30 mars 2017 - 10:35
From a table I send block of emails to individual mail addresses. This works fine as long as I am sending to a single email address.

I can send to two addresses at the same time using SMTP by placing a semi-colon between the two on a single line e.g.

fred@one.com;jack@one.com.

However, this does not work if you are using Outlook and is rejected by it.

My solution was :-

Mymessage.Recipient[1] = "fred@one.com"
Mymessage.Recipient[2] = "jack@one.com"

This appeared to work but if I sent the next email to just one recipient then it also sent it to the second recipient of the previous email. So if I sent the next one to john@two.com it also sent the same email to jack@one.com

If the next email after that is also going to a single recipient then it also sends a copy to jack@one.com.

All puzzling since I send as totally individual emails and start each one with a new session using EmailStartOutlookSession and end them with EmailCloseSession. I even added EmailReset() after to clear all information before the next email.

When it creates an email to a single recipient it just runs Mymessage.Recipient[1] and when there are two then it sends to both recipients.

I desperation I tried adding Mymessage.Recipient[2] = "" but they then fail.

I have also tried Mymessage.CC[1] but that gives the same result of sending to an additional address..

My current solution is to pull out the addresses and send individual emails to each thus avoiding the use of Recipient[2]. This does work but it seems like a heavy solution when compared to using a semi-colon with SMTP.

Any ideas?

Norman
Posté le 30 mars 2017 - 15:25
Hi Norman,

This solution is the right one
Mymessage.Recipient[1] = "fred@one.com"
Mymessage.Recipient[2] = "jack@one.com"


But it is INCOMPLETE!
You ALSO need to setup the .NBRecipient property so that the system
knows how many lines of the aray to consider

best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

Ready for you: WXShowroom.com, WXReplication (open source) and now WXEDM
(open source)

More information on http://www.fabriceharari.com
Posté le 31 mars 2017 - 11:13
Thanks for suggestion. I only have one customer using Outlook and that is because their ISP gave them an Exchange Server account. It's using Outlook 2016. I get the same issue on my Outlook 2016 and I am not using Exchange Server. Mind you, I normally use Thunderbird as a mail client and have never had a problem.

I declared this at the top of the code -

MyMessage is Email
sDefaultProfile is string = OutlookDefaultProfile()

But the NBRecipient does not appear in the list of available properties after I type -

Mymessage.

I am able to type -

Email.NbRecipient = 1 etc

and set this to the number of addresses but it gives the original issue of duplication. I trust it hasn't actually done anything.

I have discovered that Outlook uses a comma as an additional address separator in Options rather than a semi-colon, since this appeared to be the original issue I altered the delimiter to a comma by programming in my original code but it still does not work. So altering fred@one.com;jack@one.com to fred@one.com,jack@one.com still fails.

If I type fred@one.com;jack@one.com or fred@one.com,jack@one.com on the TO line of Outlook then they both work.

Sending to one address at a time using Outlook in my program works fine.

Norman