cancel
Showing results for 
Search instead for 
Did you mean: 

Error creating email attachment when sending email attachment using "Send Mail" operator

jyothiraghav_jinka
Participant
0 Kudos

Hi All

I am facing an error "could not create an attachment" using the "Send Mail" operator in DI.

Attaching the flow for reference.

I am reading a csv file then converting the file object into a string to send it to python operator to construct the message attributes for "Send Mail" operator as below.

attr = dict()
attr["email.attachments"] = [input_csv_file_msg_string]
attr["email.subject"] = "Test"
attr["email.from"] = "alice@example.com"
attr["email.to"] = ["bob@example.com"]
msgbody = ("Test")
messageout = api.Message(body=msgbody, attributes=attr)

Could you please assist if there are any other attributes I need to construct before sending it to the "Send Email" operator ?

Thanks
Raghav

Accepted Solutions (1)

Accepted Solutions (1)

jyothiraghav_jinka
Participant
0 Kudos

I was able to resolve the issue. The value to be sent to the attachment is only the name of the file and the file path needs to start with /vrep/<path>. So you cannot send the attachments on the fly. This needs to be a saved file object.

amish1980_95
Participant
0 Kudos

Hello Jyothi,

I am facing the same issue of 'can not create attachment, however, I have saved the file in system mgmt and consuming the same in python operator but it is still failing.

I have saved the output of message.error port of pipline operator into a file thru write file operator, the output of write file operator is given as an input to pyhton operator.

def on_input_er1(error):

attributes = {

"email.from": "ik@gmail.com",

"email.to": ["ik@abc.com"],

"email.subject": "Test mail from SAP DI",

"email.attachments": ["/files/vrep/exception.txt"]

};

send_body= "Dear User,\n\nException occured while loading data from DB to SRC HANA table:" + "\n\nError details are below:\n\n" + "Error Code["+str(Error_Code)+"] " + "Type of failure["+str(Error_Type)+"] failed at datetime["+date_time_str+"] " + "for the table["+str(t_name)+"]" + " and the graph name["+str(api.graph_name)+"]." + "\n\n" + "\n\n Thank you," + "\n SAP DI Team" + "\n\n" + " *** This is an automated e-mail. Please do not reply."

api.send("output", api.Message(attributes=attributes, body=send_body))

Can you plz advise?

Thanks,

Indu.

jyothiraghav_jinka
Participant
0 Kudos

Hi Indu

I observe that the path you have mentioned is "/files/vrep/exception.txt". Can you try with "/vrep/exception.txt" ?

Thanks

Raghav

amish1980_95
Participant
0 Kudos

Thanks Raghav.

I tried following:

"/tmp/exception.txt"

"/vrep/exception.txt"

"/files/tmp/exception.txt"

"/files/vrep/exception.txt"

but nothing works.

amish1980_95
Participant
0 Kudos
Modeler Version:3.1.53, Data Intelligence Version:3.1.13
amish1980_95
Participant

Hello Raghav,

Issue sorted, the change is basically at selecting the root dir in system mgmt.
/ instead of /files/

Thanks,

IK

Answers (1)

Answers (1)

0 Kudos

Hi,

Can use Receive email operator to save attachment in DI data lake..?

Its output port say's as below

Output

  • out: A message containing the Message Attributes and the Body of an email. The email body can be either in ‘plain-text’ format or ‘HTML’ format.

Any Work around...?

Not sure with help of Python we can read ‘plain-text’ format or ‘HTML’ format and get the attachment.

Thanks.

Deepak.