Issue with custom sendmail function

Issue with custom sendmail function

Hello!

I am having an issue with a sendmail function that has been in use but my organization is looking to add more detail to it. The custom function sends an email to a pick list user but I do not know how it determines which email address to send to.

We are looking to add information such as order and deal names, which are being pulled from a "Deals" module. When I try to add the fields in the script, it seems to break the function and i'm not sure why.

Here is a screen shot of the untouched function in working form:



It currently gets the account name but not the order name (commented out section). I tried creating an order = line based on what the account = line but this is where it breaks the function. Trying to add Order name to this automated email.

Any thoughts?