Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to store email content as a document variable?

Avatar

Level 8
Level 8
Hi there,



I have a question where I need to store the content of an email-service into a txt-file. I guess I should somehow put it in an document variable, how can this be done?



Thanks in advance



Sincerely

Kim
9 Replies

Avatar

Level 10
Just use a set value and assign the content of the email to the document variable.



The document variable can contain pretty much anything, so it should work.



Jasmin

Avatar

Level 8
Level 8
Hi again,

Im not sure I understand you correctly. I mean I have an send-email service, which has a subject, some content (containing xpath-expressions), and some other stuff set up. So I need all of the information in this send-email service put into a txt file and save it for archiving. How is this possible? I don't know how to get my hands on these properties.



Can you help me here?



Sincerely

Kim

Avatar

Former Community Member
Kim



I would suggest one of the following two methods:



1) Prior to sending the email with the SendEmail service, build the email contents via SetValues and using String process variables. Have one String for the subject (i.e. sSubject) and one for the body (i.e. sBody) and build your content appropriately. You can use multiple SetValues or you could do it all in one. After your email's body is done being built, use a SetValue to set it to a Document variable (i.e. docBody = sBody). You can then use this Document variable as the input to your SendEmail service's body parameter. What you have then is a Document containing all the content of the email's body that you can now write to the filesystem, archive to a repository or do whatever you'd like with. Please note that if you are using HTML formatting for the email's body that your Document variable will literally have the HTML code in it. This means that if you, say, archived the Document to the file system as a .txt and then opened it, you would see all the content but it would have all the HTML code with it. To get around this, you might consider archiving the email contents as a .htm or .html file. This will cause the file to open in the system's default browser for viewing but it will also only display the actual content formatted per your HTML code.



One other thing to note is that if you wanted the subject to be part of the archived file's contents as well, you could simply do a String concatenate of the body String (sBody) to the subject String (sSubject).



2) If the emails you are sending go to the same email box(es) each time, you might consider building a second orchestration that uses an Email endpoint to watch the box(es). With this, you could monitor those inboxes and handle incoming messages appropriately.



Please do let me know if you have any questions.



Josh Boyle

jboyle@cardinalsolutions.com

Cardinal Solutions Group

Avatar

Level 8
Level 8
Hi again Josh,



Thank you for your very precise description. Your suggestion will work fine - I had just hoped that there was an easier way than using concat and set values. Also I am not sure how the XPath-expressions will be handled (if they will be evaluated) when I build up the body as a string. But I will definately try to do it.



I will ask again if )I run into any problems



Once again - thank you for your help.



Sincerely

Kim

Avatar

Former Community Member
Kim



Any process variables you reference with a SetValue will be evaluated accordingly. For example, the following right-hand expression stored in the sBody String variable.....



concat('Thank you for contacting the IT Help Desk.



Your ticket number is: ', /process_data/@sTicketNum)



would result in the following email body (assuming HTML is enabled and your ticket number is 1234321):



Thank you for contacting the IT Help Desk.



Your ticket number is: 1234321



Note that since you are building your Body string ahead of time in SetValues, you won't have to worry about referencing your process variables like {$ /process_data/@sTicketNum $}. This is because your ticket number has already been evaluated and stored in the sBody variable prior to being passed to the SendEmail service.



As always, please do let me know if you have any questions!



Josh Boyle

jboyle@cardinalsolutions.com

Cardinal Solutions Group

Avatar

Level 10
You can also just specify your variable using "template" as oppose to "variable" or "xPath". That way you don't need to use concat() to concatenate all the strings together.



Using "template" you can just type your text and include the xPath right into the text. For the body, you could write something like:



Thank you for contacting the IT Help Desk.



Your ticket number is: {$/process_data/@sTicketNum$}.



No need to use any concat().



Jasmin

Avatar

Level 9
Hi Kim

We've been contemplating a custom component for doing just what you're asking. In addition, it would provide an audit trail of all mails sent, as well as the ability to manually change the parameters, and resend the email if it failed.



Would this be of interest?

If so, please contact info@avoka.com

Thanks,

howard

Avatar

Level 8
Level 8
Hi again all,



Thanks for your answers - I will try to use the most suitful for my purpose.



One question to you though Jasmin - using the template, how can I save the email text in a vatriable. As I see it I can not store the value of a template into a process variable, but I might be wrong?



Thanks in advance



Sincerely

Kim

Avatar

Former Community Member
Here's my $.02:



In my opinion, LiveCycle is not the best place to perform this logging. LiveCycle is not actually sending the email, it's just sending a request to a mail server to send the email. Therefore, LiveCycle would not have important information about the email, such as the actual sent date/time, whether it was able to be delivered, email headers, etc.



One of my customers required that some of the email messages sent by LiveCycle be archived for compliance purposes. We decided to leverage the capabilities of the Exchange server. What we did was set up a public Outlook folder and email-enabled it with a mail address ('lcnotif@acme.com' for example). What this allows you to do is send an email to that address and it will automatically be archived into the public folder. For more information on setting this up, see the following article:

http://www.msexchange.org/articles/MF021.html



What we then did was any time we needed to archive an email that was being sent from LiveCycle, we BCC-ed the 'lcnotif@acme.com' address, which meant that a copy of it would be sent to the public folder. This gave us several benefits:

1) It gave us an accurate audit trail of the emails sent by LiveCycle, including date/timestamps, recipients, and a full email header that could be examined if necessary.

2) It gave us a central location where the audit history could be stored and permissions could be assigned to individuals or groups for viewing the history.

3) It allowed us to leverage some of the retention policies available with Outlook. For this customer, the messages only needed to be saved for 60 days. A retention policy was set up to automatically delete the messages after 60 days.



This gave us a very nice solution with a very minimal amount of effort and zero customization on the LiveCycle side.



Justin Klei

Cardinal Solutions Group