Question

Add order's attachments to email

Hi there,

 

I'm trying to create a business process that sends an email with all the order's attachments.

 

Would love to know how should it be done.

 

Many thanks,

Oren

Like 0

Like

2 comments

Hello Oren, 



The mentioned functionality can be implemented in business process using a script task element and creating a correct script for it. 



For example, here is the script which will copy all attachments from lead to opportunity:



var userConnection = Get<UserConnection>("UserConnection");

Guid fromID = Get<Guid>("fromId");

Guid toID = Get<Guid>("toId");

string sql =String.Format("INSERT INTO OpportunityFile (Name, Data, TypeId, LockedById, LockedOn, Version, OpportunityId) SELECT Name, Data, TypeId, LockedById, LockedOn, Version, '{0}' FROM FileLead WHERE LeadId = '{1}'", toID, fromID); 

CustomQuery myQuery = new CustomQuery(userConnection);

myQuery.SqlText = sql;

using (DBExecutor dbExecutor = userConnection.EnsureDBConnection())

{

    dbExecutor.CommandTimeout = 0;

    myQuery.Execute();

}

return true;



You may use this script as example and create a new one with the needed functionality upon it. 



Best regards, 

Roman

Roman Brown,

Hi Roman,

is there a way to achieve such functionality by using pure workflow functionality with Script Tasks?

I have created a Lookup with nested lookup to document attachments. I want to use this attachment to add it to an email through a workflow. Is there any way to add email attachments with workflow steps without the Script Task?

Show all comments