Hello Creatio Community,
I'm creating a script task for email sender using a documentation from creatio team. I followed the provided instructions for creating the script task, but when I published the script task some errors occured.
Some of the classes and interface cannot be found also the IntegrationApi library cannot be found.
source code below :
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using Terrasoft.Common;
using Terrasoft.Core;
using Terrasoft.Core.Configuration;
using Terrasoft.Core.DB;
using Terrasoft.Core.Entities;
using Terrasoft.Core.Factories;
using Terrasoft.Core.Process;
using Terrasoft.Core.Process.Configuration;
using Terrasoft.Mail;
using Terrasoft.Mail.Sender;
using IntegrationApi;
var mailBoxSettingId = Get("SenderMailbox");
var emailClientFactory = ClassFactory.Get(
new ConstructorArgument("userConnection", UserConnection));
var emailSender = ClassFactory.Get(
new ConstructorArgument("emailClientFactory", emailClientFactory),
new ConstructorArgument("userConnection", UserConnection));
var entity = UserConnection.EntitySchemaManager.GetInstanceByName("MailboxSyncSettings").CreateEntity(Uif (entity.FetchFromDB("Id", mailBoxSettingId, new List { "SenderEmailAddress" })) {
var senderEmailAddress = entity.GetTypedColumnValue("SenderEmailAddress");
var message = new Terrasoft.Mail.Sender.EmailMessage {
From = senderEmailAddress,
To = Get("Recipient").Split(';').ToList(),
// Cc = List{ "first@recepient.co", "second@recepient.co"},
// Bcc = List{ "first@recepient.co", "second@recepient.co"},
Subject = Get("Subject"),
Body = Get("Body"),
Priority = Terrasoft.Mail.Sender.EmailPriority.Normal
};
var attachment = new Terrasoft.Mail.Sender.EmailAttachment {
Id = Guid.NewGuid(),
Name = "test.txt",
Data = Encoding.ASCII.GetBytes("some test text")
};
message.Attachments.Add(attachment);
emailSender.Send(message);
}
return true;
errors in lines :
var emailClientFactory = ClassFactory.Get(
var emailSender = ClassFactory.Get(
var message = new Terrasoft.Mail.Sender.EmailMessage {
Priority = Terrasoft.Mail.Sender.EmailPriority.Normal
var attachment = new Terrasoft.Mail.Sender.EmailAttachment {
Documents in this link:
page 14: https://academy.creatio.com/docs/sites/academy_en/files/pdf/node/1474/Sending_emails_.pdf
https://academy.creatio.com/docs/7-18/developer/application_components/…
Like
Hello Alba,
Thanks for your question.
I am glad to assist you however it is hard to understand what causes the error without error messages. Could you please enable tracing for you business process and share the error message?
This code works fine for me:
Hope this helps
Alba,
I had the same issue following the same article.
Then I decided to do differently. No code is needed :
By using the element process file you can generate the printable then using the file in the process allows you to add the file generated in the email as attachment, you don't need to store the file in an activity record.
Tell me if you need more details.