# email getting two times while payment made at a time  to multiple vendors in ax 2009?

**URL:** <https://www.dynamicsuser.net/t/email-getting-two-times-while-payment-made-at-a-time-to-multiple-vendors-in-ax-2009/60805>\
**Category:** Developer Forum\
**Created:** [May 27, 2016, 9:20am UTC](https://www.dynamicsuser.net/t/email-getting-two-times-while-payment-made-at-a-time-to-multiple-vendors-in-ax-2009/60805 "2016-05-27T09:20:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vamshidher](https://avatars.discourse-cdn.com/v4/letter/v/91b2a8/32.png) [@vamshidher](https://www.dynamicsuser.net/u/vamshidher)\
**Post date:** [May 27, 2016, 9:20am UTC](https://www.dynamicsuser.net/t/email-getting-two-times-while-payment-made-at-a-time-to-multiple-vendors-in-ax-2009/60805/1 "2016-05-27T09:20:08Z")

</div>

Hi team ,

I am facing one issue while made a payment to multiple vendors at a time .

scenario : whenever I made payment to vendor (Payment Journal posting) then mail should go to that vendor respective mail id with details of Invoice number , Invoice Date and Invoice Amount  
if I select one vendor it going fine with details ,but while selecting multiple vendors to made payment at a time ,that time mail should go to two different vendors with there respective mail ids and details .but 1st vendor getting to two mails (1st vendor details as well as 2nd vendor details )… .it is happeing while sending mail to 2nd vendor (in" to address" [vendor1@gmail.com](mailto:vendor1@gmail.com) ,vendor2@gmail.com (it is appending 1 st vendor mail id )) , so thats why mail comeing to 1 st vendor 2 times

suppose one vendor" flip kart" and second vendor is “Amazon” . i configure mail id both vendors in vendor details form

Flipkart - [Flipkart@gmail.com](mailto:Flipkart@gmail.com) ,amazon : [amazon@gmail.com](mailto:amazon@gmail.com) but while payment to two vendors at time filpkart getting mail and amazon getting mail with respective deatils .but 2nd vendor sending mail time it is takeing (appending 1 st vendor mail id ) . so flipkart vendor getting two mails with deatils of amazon .

i changed this code :

static void sendEmail(container con)//LedgerJournalTrans parmLedgerJournalTrans)  
{  
SysMailer mailer = new SysMailer();  
SysEmailParameters parameters = SysEmailParameters::find();  
str emailFrom = sysuserInfo::find(curUserId(),false).Email;  
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);  
str \_emailTo;  
str \_subject;  
str \_bodyText;  
int i;  
LedgerJournalTrans parmLedgerJournalTrans;  
Recid recid;  
;  
for(i =1 ; i \<= conlen(con); i++)  
{  
recid = conpeek(con, i);  
select firstonly \* from parmLedgerJournalTrans  
where parmLedgerJournalTrans.RecId == recid;  
info(strfmt("%1", parmLedgerJournalTrans.AccountNum));  
\_emailTo = vendtable::find(parmLedgerJournalTrans.AccountNum).Email;  
\_subject = “Payment Notification “;  
\_bodyText = “Following payment is credited to your account :– " + “\n” + " Invoice Number = " + “\n” + parmLedgerJournalTrans.Invoice  
+” Invoice Date = " +”\n” + Strfmt("%1",parmLedgerJournalTrans.TransDate) +"\n"+ " Invoice Amount = " + “\n” + strfmt("%1", parmLedgerJournalTrans.amount());  
CodeAccessPermission::revertAssert();  
permission.assert();  
if (\_emailTo != “”)  
{  
if (parameters.SMTPRelayServerName)  
{  
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,  
parameters.SMTPPortNumber,  
parameters.SMTPUserName,  
SysEmailParameters::password(),  
parameters.NTLM);  
}  
else  
{  
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,  
parameters.SMTPPortNumber,  
parameters.SMTPUserName,  
SysEmailParameters::password(),  
parameters.NTLM);  
}  
mailer.fromAddress(emailFrom);  
mailer.tos().appendAddress(\_emailTo);  
mailer.subject(\_subject);  
mailer.htmlBody(\_bodyText);  
mailer.sendMail();  
}  
CodeAccessPermission::revertAssert();  
}  
}

what are the changes i need to change in this code ?

any suggestions …

thanks ,

---

<div class="post-metadata">

**Author:** ![kunal\_patel](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@kunal\_patel](https://www.dynamicsuser.net/u/kunal_patel)\
**Post date:** [May 30, 2016, 2:31pm UTC](https://www.dynamicsuser.net/t/email-getting-two-times-while-payment-made-at-a-time-to-multiple-vendors-in-ax-2009/60805/2 "2016-05-30T14:31:01Z")

</div>

you have used the info in your code , what is the output of that info?

info(strfmt("%1", parmLedgerJournalTrans.AccountNum));

---

<div class="post-metadata">

**Author:** ![vamshidher](https://avatars.discourse-cdn.com/v4/letter/v/91b2a8/32.png) [@vamshidher](https://www.dynamicsuser.net/u/vamshidher)\
**Post date:** [May 31, 2016, 7:51am UTC](https://www.dynamicsuser.net/t/email-getting-two-times-while-payment-made-at-a-time-to-multiple-vendors-in-ax-2009/60805/3 "2016-05-31T07:51:52Z")

</div>

thanks for replay … i just added one line code after mailer.send method …i.e : mailer.tos().clear ;  
But now i am facing i am unable to get Invoice number and Invoice date ? where we will take this two fields ?
