Email
attachment
Business Process
7.11
sales

Is there a way to send an attachment inside of a business process?

  • The attachment location/directory is data driven, different for each contact
Like 0

Like

4 comments

Dear John,

 

Here's the method that can be used to implement sending the attachments within business process:

		public static bool SendMail(string mailto, string caption, string message, Guid FileId, string SchemaName, UserConnection userConn) {
			SchemaName+="File";
			string smtpServer = Terrasoft.Core.Configuration.SysSettings.GetValue(userConn, "SFsmtpServer").ToString();
			string from = Terrasoft.Core.Configuration.SysSettings.GetValue(userConn, "SFFrom").ToString();
			string password = Terrasoft.Core.Configuration.SysSettings.GetValue(userConn, "SFPassword").ToString();
			Stream FileA = null;
			string Fname = "";
			var esq = new EntitySchemaQuery(userConn.EntitySchemaManager, SchemaName);
			esq.AddAllSchemaColumns();
			esq.Filters.Add(esq.CreateFilterWithParameters(FilterComparisonType.Equal, "Id",FileId));
			var coll = esq.GetEntityCollection(userConn);
			foreach(var ent in coll) {
				FileA = ent.GetStreamValue("Data");
				Fname = ent.GetTypedColumnValue<string>("Name");
				break;
			}
			try {
				MailMessage mail = new MailMessage();
				mail.From = new MailAddress(from);
				mail.To.Add(new MailAddress(mailto));
				mail.Subject = caption;
				mail.Body = message;
				mail.IsBodyHtml = true;
				if (FileA != null)
					mail.Attachments.Add(new Attachment(FileA, Fname));
				SmtpClient client = new SmtpClient();
				client.Host = smtpServer;
				client.Port = 587;
 
				client.EnableSsl = true;
				client.Credentials = new NetworkCredential(from.Split('@')[0], password);
				client.DeliveryMethod = SmtpDeliveryMethod.Network;
 
				client.Send(mail);
				mail.Dispose();
				return true;
			} catch(Exception e) {
				throw new Exception("Mail.Send: " + e.Message);
			}
		}

Please note that in this case the file is taken from Attachments and Files tab of the record. If you want to take the file from the external resource you'll need to develop the additional integration.

Lisa

 

Lisa Brown,

Is posible select the sender mailConfiguration? This code take the default email. I need select a shared configuration.

Lisa Brown,

Please feel free to use ESQ to find the mailbox that you need.

https://academy.bpmonline.com/documents/technic-sdk/7-11/use-entitysche…

All user mailboxes are in the MailboxSyncSettings table.

Eugene Podkovka,

Hi, using the script above, is it possible to let the user edit the email message before sending? (like you can do when you use the [ Send email ]?

Show all comments

Watch the new bpm'online video tutorial, "Working with emails", and learn how to synchronize with your mailboxes, bind incoming emails to accounts, contacts and other system records, send emails directly from bpm’online and much more. 

Watch it here.

File attachments

Like

0 comments
Show all comments

Below you can find the instruction on how to set up the integration of bpm’online with MS Office 365.

Steps 1-2 have to be performed once by user with system administrative rights.

Steps 3-4 have to be performed by every user that will use synchronization with its Office 365 mailbox.

 

  1. Go to ‘System Designer’ – ‘Advanced Settings’ to add a new email provider:

 

2. Select ‘Microsoft Exchange ActiveSync’ option, specify the parameters you see on the screenshots:

3. Open ‘User’s Profile’ – select ‘Email Accounts’ – ‘New’:

4. Enter mailbox parameters, save the changes:

 

Like 3

Like

0 comments
Show all comments