Question
Luxoft
UA
Last activity: 4 Oct 2018 11:08 EDT
how to attach excel file to mail?
Hi everyone.
I need to do the following action:
1. We have page list with data and generated Excel file with these data
3. Need to send email with this Excel File.
We are doing it out of WO. How to attach Excel file to mail?
I see many topics about the same issue on PDN, but still can't find any solution for it.
Thanks in advance for your help
**Moderation Team has archived post**
This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.
-
Likes (1)
Anne Morrow -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Updated: 9 Oct 2015 15:21 EDT
Luxoft
UA
Hi all, going to provide a simple case of my task.
Pre-condition:
- Page List with the data below. TempPage(code-pega-list). TempPage.pxResults() - q-w-e-r-t-y class
TempPage.pxResults(1).Test1 = "X1";
TempPage.pxResults(2).Test1 ="X2";
TempPage.pxResults(3).Test1 ="X3".
===================================================
My solution:
1. To create a new activity AttachExcelToMail.
2 To create HTML rule GenerateExcelStructure with the content below:
===========================================================
<html>
<body>
<table border="1">
<tr>
<th>Test1</th>
</tr>
<pega:forEach name="TempPage.pxResults">
<pega:withEmbedded name="$THIS">
<tr>
<%
String Test1= tools.getStepPage().getString("Test1");
tools.appendString("<td wrap>" + Test1+ "</td>");
%>
</tr>
</pega:withEmbedded>
</pega:forEach>
</table>
</body>
</html>
========================================================
Hi all, going to provide a simple case of my task.
Pre-condition:
- Page List with the data below. TempPage(code-pega-list). TempPage.pxResults() - q-w-e-r-t-y class
TempPage.pxResults(1).Test1 = "X1";
TempPage.pxResults(2).Test1 ="X2";
TempPage.pxResults(3).Test1 ="X3".
===================================================
My solution:
1. To create a new activity AttachExcelToMail.
2 To create HTML rule GenerateExcelStructure with the content below:
===========================================================
<html>
<body>
<table border="1">
<tr>
<th>Test1</th>
</tr>
<pega:forEach name="TempPage.pxResults">
<pega:withEmbedded name="$THIS">
<tr>
<%
String Test1= tools.getStepPage().getString("Test1");
tools.appendString("<td wrap>" + Test1+ "</td>");
%>
</tr>
</pega:withEmbedded>
</pega:forEach>
</table>
</body>
</html>
========================================================
Activity AttachExcelToMail.
1. Property-set-HTLM.
param.pyFileData = "GenerateExcelStructure"
2. Java
String strFileData = getParameterValue("pyFileData");//getPrimaryPage().getValue("pySrc"); Page objHeadersPage = getProperty("pxRequestor.pyHTTPResponseHeaders").getAsPage(); if (objHeadersPage.isBound()) { objHeadersPage.setValue("contentType" ,"application/vnd.ms-excel"); sendData("", strFileData); } else { sendData("","Error. Can't get \"pxRequestor.pyHTTPResponseHeaders\" page"); }
3. Page-New
AttachmentLinksOpened page (code-pega-list)
4. Property-Set
- AttachmentLinksOpened.pxResults(<APPEND>).pxObjClass = 'Data-WorkAttach-File'
- AttachmentLinksOpened.pxResults(<LAST>).pyAttachStream = PegaFunction Base64Encode(param.strFileData).
5. Page-New AttachmentPage ( Data-EmailAttachments)
6. Property-Set
- AttachmentPage.pyAttachment(<APPEND>).pyDecode == True
- AttachmentPage.pyAttachment(<APPEND>).pyName == "ExportReport.xls"
- AttachmentPage.pyAttachment(<APPEND>).pyReference == AttachmentLinksOpened.pxResults(1).pyAttachStream
- AttachmentPage.pyAttachment(<APPEND>).pyRemoveXML == False
If you have any comments please let me know.
Hope this article help you.
Thanks.
Pegasystems Inc.
IN
Hi
can you please elaborate on the point "We are doing it out of WO "
If it is something like you want to send email out of your workobject with an attachment then you can refer this help article : https://community.pega.com/sites/default/files/help_v718/procomhelpmain.htm
-
Susovan Bandyopadhyay
Luxoft
UA
Santanu, thanks for the help.
One more question.
I have the following content of my Excel file.
=====================================================================
<html>
<body>
<table border="1">
<tr>
<th>test1</th>
</tr>
<tr>
<td wrap>value1</td><td wrap>value1</td><td wrap>value1</td><td wrap>value1</td>
</tr>
</table>
</body>
</html>
=====================================================================
How can i put this value in pyReference property?
Thanks in advance.
Luxoft
UA
Update, the question still open.
Luxoft
UA
Hi all,
Half of the issue is solved.
1) I created AttachmentLinksOpened page (code-pega-list).
2) Set AttachmentLinksOpened.pxResults(<APPEND>).pxObjClass = 'Data-WorkAttach-File' and AttachmentLinksOpened.pxResults(<LAST>).pyAttachStream = "content of my Excel file".
3) Set pyReference as AttachmentLinksOpened.pxResults(1).pyAttachStream
Now I can send email with Excel file, but Excel file has incorrect data (some strange characters)
Any ideas?
Thanks in advance for the help
Luxoft
UA
Hi all,
The issue is fully solved.
Going to provide all(requirement and solution) later.
Accepted Solution
Updated: 9 Oct 2015 15:21 EDT
Luxoft
UA
Hi all, going to provide a simple case of my task.
Pre-condition:
- Page List with the data below. TempPage(code-pega-list). TempPage.pxResults() - q-w-e-r-t-y class
TempPage.pxResults(1).Test1 = "X1";
TempPage.pxResults(2).Test1 ="X2";
TempPage.pxResults(3).Test1 ="X3".
===================================================
My solution:
1. To create a new activity AttachExcelToMail.
2 To create HTML rule GenerateExcelStructure with the content below:
===========================================================
<html>
<body>
<table border="1">
<tr>
<th>Test1</th>
</tr>
<pega:forEach name="TempPage.pxResults">
<pega:withEmbedded name="$THIS">
<tr>
<%
String Test1= tools.getStepPage().getString("Test1");
tools.appendString("<td wrap>" + Test1+ "</td>");
%>
</tr>
</pega:withEmbedded>
</pega:forEach>
</table>
</body>
</html>
========================================================
Hi all, going to provide a simple case of my task.
Pre-condition:
- Page List with the data below. TempPage(code-pega-list). TempPage.pxResults() - q-w-e-r-t-y class
TempPage.pxResults(1).Test1 = "X1";
TempPage.pxResults(2).Test1 ="X2";
TempPage.pxResults(3).Test1 ="X3".
===================================================
My solution:
1. To create a new activity AttachExcelToMail.
2 To create HTML rule GenerateExcelStructure with the content below:
===========================================================
<html>
<body>
<table border="1">
<tr>
<th>Test1</th>
</tr>
<pega:forEach name="TempPage.pxResults">
<pega:withEmbedded name="$THIS">
<tr>
<%
String Test1= tools.getStepPage().getString("Test1");
tools.appendString("<td wrap>" + Test1+ "</td>");
%>
</tr>
</pega:withEmbedded>
</pega:forEach>
</table>
</body>
</html>
========================================================
Activity AttachExcelToMail.
1. Property-set-HTLM.
param.pyFileData = "GenerateExcelStructure"
2. Java
String strFileData = getParameterValue("pyFileData");//getPrimaryPage().getValue("pySrc"); Page objHeadersPage = getProperty("pxRequestor.pyHTTPResponseHeaders").getAsPage(); if (objHeadersPage.isBound()) { objHeadersPage.setValue("contentType" ,"application/vnd.ms-excel"); sendData("", strFileData); } else { sendData("","Error. Can't get \"pxRequestor.pyHTTPResponseHeaders\" page"); }
3. Page-New
AttachmentLinksOpened page (code-pega-list)
4. Property-Set
- AttachmentLinksOpened.pxResults(<APPEND>).pxObjClass = 'Data-WorkAttach-File'
- AttachmentLinksOpened.pxResults(<LAST>).pyAttachStream = PegaFunction Base64Encode(param.strFileData).
5. Page-New AttachmentPage ( Data-EmailAttachments)
6. Property-Set
- AttachmentPage.pyAttachment(<APPEND>).pyDecode == True
- AttachmentPage.pyAttachment(<APPEND>).pyName == "ExportReport.xls"
- AttachmentPage.pyAttachment(<APPEND>).pyReference == AttachmentLinksOpened.pxResults(1).pyAttachStream
- AttachmentPage.pyAttachment(<APPEND>).pyRemoveXML == False
If you have any comments please let me know.
Hope this article help you.
Thanks.
Updated: 8 Feb 2016 5:37 EST
Cotiviti
IN
Thanks for this post.
I did some changes to make it work for me.
AttachmentPage.pyAttachments(<APPEND>).pyDecode == True
- AttachmentPage.pyAttachments(<LAST>).pyName == "ExportReport.xls"
- AttachmentPage.pyAttachments(<LAST>).pyReference == "AttachmentLinksOpened.pxResults(1).pyAttachStream" {Reference in double quotes}
- AttachmentPage.pyAttachments(<LAST>).pyRemoveXML == False
No need to call Java step. Directly put pyFileData as reference
AttachmentLinksOpened.pxResults(<LAST>).pyAttachStream = PegaFunction Base64Encode(param.pyFileData).
!Thanks
Ajay
Tata Consultancy Services
GB
What would be next step after populating AttachmentPage.pyAttachements?
I called SendEmailWithAttachments after setting pyreference and supplied the required parameters. I did get the email but without attachment.
Can you please elaborate what steps did you add after it?
Updated: 6 Apr 2016 1:53 EDT
Cotiviti
IN
Hi Arjun Shaw
After setting values AttachmentPage
I put a Property-Set
param.AttachmentPage = "AttachmentPage"
And just calling 'SendEmailWithAttachments' worked for me.
Thanks
Ajay
Tata Consultancy Services
GB
Hi Ajay,
It worked for me when I called the OOTB function SendEmail with the parameter as AttachmentPage.
Calling OOTB Activity SendEmailWithAttachments is not working in this case.
Thanks for your input.
Regards,
Arjun Kumar Shaw