Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

Sending email template by code based on template

Posted on by 11,873

I have a code sending email with attachment based email template , the issue is that a copy of the email is sent to the email specified as sender , how can I stop this ?

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Sending email template by code based on template

    Hi Maram,

    Is the recipient a shared email box or a natural person? Is it an internal or external person? Could it be a setting on your Exchange Server or Office 365?

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Sending email template by code based on template

    Hi ergun sahin ,

    no customization on sysEmailDistributor

    But I think ( but not sure just a guessing) that there is a property on the system level makes email distributor send a copy to sender or may be at email template I check different parts but until now I cannot find anything

  • ergun sahin Profile Picture
    ergun sahin 8,812 Super User 2024 Season 1 on at
    RE: Sending email template by code based on template

    Hi Maram,

    I can't see anything that would require sending it twice in this code.

    Maybe a customization caused this. Can you check the SysOutgoingEmailTable (or data) table for copied records.

    Do you have a workflow in the template.

    You can try with othter templates or without any template.

    You can insert data with other status.

    You can look sysEmailDistributor class for any customization

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Sending email template by code based on template

    its select not while select so even if there is two records only one record will be processed .

  • Jay Barot Profile Picture
    Jay Barot 1,502 on at
    RE: Sending email template by code based on template

    Screenshot_5F00_20200607_2D00_163024_7E00_2.png

    i was talking about this. 

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Sending email template by code based on template

    Hi Jay,

    I do not have any join query in my code

  • Suggested answer
    Jay Barot Profile Picture
    Jay Barot 1,502 on at
    RE: Sending email template by code based on template

    Hi Maram,

    Can you check the joins used in code. Either it's getting 2 records because 2 conditions for emailId field.

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Sending email template by code based on template

    Hi Ludwig ,

    I have custom report convert to pdf and and I send it to worker . This part works correctly but the issue is that the sender also receives a copy from the same email.

    Environment is D365FO

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Sending email template by code based on template

    Hi André ,

    _emailAddr contains the email of  the user linked with certain worker and yes I am sure that it contains only one email . if the method called more than one time I expect that the receiver will receive multiples email not the email sent to different receivers  

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,269 Super User 2024 Season 2 on at
    RE: Sending email template by code based on template

    Hi Maram,

    What is the value provided in the variable '_emailAddr'? Is this containing one or multiple addresses? Did you check using the debugger how many times this method is being executed?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans