You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

attachment in send mail function

9 replies [Last post]
Guest's picture
Guest

Hi.
I need an urgent help..
i have to create one batch process(App engine) in which everyday it will fetch all the employees who are getting transfer and it will trigger a mail to them with their transfer details in attachment (pdf )in the same mail .

I know about send mail function through which we can trgger a mail with a general attachment.but how to fetch dynamic values for each and every employee in the attachement (pdf),i have no idea.

Kindly help me out.

Thanks
Piyali

CompShack's picture
User offline. Last seen 3 years 11 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Use Do Select

Hi Piyali,

It sounds like you need to use Do Select followed by a PeopleCode action to email the pdf for each employee (one employee at a time "Do Select").

The Do Select will enable you to process all rows returned, in your case, all employees who are getting transfered.

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

Piyali's picture
Piyali (not verified)
Hi..

Hi..
thanks A lot for replying..

But in sendmail function we can just give a path of the file and only one fixed format can be sent.But i want to place the employee id .transfer date ,location in that pdf file..how to do that???

we genarally sendmail syntax we attach file like this.
&MAIL_FILES = "c:\temp\Transfer.pdf";.

I have to pass the my values in that" Transfer.pdf"

Like dear Amar ,
---------
You are gettiing tansfer to Australia.
--------------

how to put "Amar " and "Australia." in the attached file.??

I am waiting for your reply..

Thanks

Piyali.

CompShack's picture
User offline. Last seen 3 years 11 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Inside your PeopleCode

Piyali,
You can pass your values inside your peoplecode action when writing to your file.

When you use the "Do Select" grab the name and country transfering to and store them in your STATE record. Then in your peoplecode action, open a new pdf file, something like this:

&userFileName = "user_file_name" | ".pdf";
&path = "path_to_your_file_directory";
&PATHNAME = &path | &userFileName;
 /** Open file for writing **/
/** PATHNAME is the both the path and the file name **/
   &UserFile = GetFile(&PATHNAME, "W", %FilePath_Absolute);

Now, you need to write the email and pass the values from your stat record as such:
/*** Writing email text ***/
&UserFile.WriteLine("Like dear " | STATE_RECORD_AET.NAME | ",");
&UserFile.WriteLine(" ");
&UserFile.WriteLine("You are getting transferred  to " | STATE_RECORD_AET.COUNTRY);

Then close the file and send the email out. The "Do Select" action will do this over and over for all users that are being transfered.

n/a
Guest's picture
Guest (not verified)
attachment

Hi..

Do Select is working fine.

I have written the code in the peoplecode action.

&LogFile = GetFile("c:\temp\HX_TRANSFER_log.txt", "w", "a", %FilePath_Absolute);

&userFileName = "Transfer" | ".pdf";
&path = "c:\temp\";
&PATHNAME = &path | &userFileName;
/** Open file for writing **/
/** PATHNAME is the both the path and the file name **/
&UserFile = GetFile(&PATHNAME, "W", %FilePath_Absolute);

/*** Writing email text ***/
&UserFile.WriteLine("Like dear " | HX_TRANSFER_AET.EMPLID | ",");
&UserFile.WriteLine(" ");
&UserFile.WriteLine("You are getting transferred to " | HX_TRANSFER_AET.TO_LOCATION);
&UserFile.close();

**************************************************

Its not writing the contents in the attachment.Pdf is getting generated but thats blank.

Kindly help.

--Piyali

CompShack's picture
User offline. Last seen 3 years 11 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Check if File is Open

You are saying the file is being created but no text in it?

Lets try this, check if the file is open before you write to it like so:

If &UserFile.IsOpen Then
      messagebox(0,"",0,0,("File is open!"));
     &UserFile.WriteLine("Like dear " | HX_TRANSFER_AET.EMPLID | ",");&UserFile.WriteLine(" ");
     &UserFile.WriteLine("You are getting transferred to " | HX_TRANSFER_AET.TO_LOCATION);
     &UserFile.close();
Else
     messagebox(0,"",0,0,("File NOT open!"));
End-if;

You can check your log file for the messagebox output. If this doesn't help then try writing to a .txt file instead of .pdf file and see what happens.

Good Luck!

n/a
P I Y A L I's picture
User offline. Last seen 8 years 47 weeks ago. Offline
Joined: 02/25/2008
Posts: 12
PDF is not getting created.

Hi..

Thank u So much For your Help.I am able to create the file and can send as attachment after writing in it.

It is happening successfully in .doc and .txt file extension.but if i put .pdf i am getting the pdf as an attachment in mail ,but pdf is not opening.
It is giving this error

"Adobe reader could not open because either it is not a supported file type or the file has been damaged for example (it was sent as an email attachment and wasnt correctly decoded.)"

i have adobe reader 7 and pdf creater 0.8.

Kindly help.

Warm Regards,
P I Y A L I

Warm Regards,
P I Y A L I

CompShack's picture
User offline. Last seen 3 years 11 weeks ago. Offline
Joined: 12/09/2007
Posts: 167
Creating PDF is not as easy!

I'm glad the .txt file is working. Creating a PDF file is not as straight forward as .txt. I personally never had to create one but I think Application Engine GP_SS_PSLP (HR Module) creates one by importing a package "import HCSC:PDF:UTIL:*;".

You might want to take a look at that one, I don't have the time to break it down to know how it is exactly doing that. It is just another thing for you to look at.

Please report back if you ever got the .pdf file to work, would love to hear how you've approached this. Good luck!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

P I Y A L I's picture
User offline. Last seen 8 years 47 weeks ago. Offline
Joined: 02/25/2008
Posts: 12
Thanks a lot

Hi..

First of all thanks for your appreciation and all your help.

I have done the same for confirmation process ,Transfer process and Separation process.previously we used to generate the letters for each and every employee manualy.Now it is going to the employee (As document .doc)with 16 dynamic fields that i have included in state record.

I have searched for that app engine GP_SS_PSLP .But didnt get.We are using peopletools 8.44 .
If you are having that just forward the same ,i will try to debug that and get the solution.

Thanks once again.

Warm Regards,
P I Y A L I

Warm Regards,
P I Y A L I

Guest's picture
Guest
RE:Excel attachment using Sendmail function inPeoplecode

Hi,

I am able to trigger mail with excel attachment but in Excel sheet the values and the heading of the column are coming side-by-side...can anyone please help me to get the data in table format...

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
8 + 8 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.