Function for e-mail with attached file


asaikk

Recommended Posts

Hi,

For an exercise, I made a sequence below;

1)function : SendEmailFile()

2)a sequence to trigger "SendEmailFile()" : TestFunctionSendEmailFile

\\ function SendEmailFile

function SendEmailFile(string FilePathSent)

email.strTo = "my@myhome.com"

email.strCC = "theboss@hishome.com"

email.strSubject = "File delivery/from DAQ"

email.strBody = "Please find the attached file"

email.strFile = FilePathSent

email.Send()

\\ TestFunctionSendEmailFile

private string FilePathSent = "C:\aa onlinesoft\datalogger\log2.xlsx"

SendEmailFile(FilePathSent)

But it did not work, with a message indicating an error on the second line of "TestFunctionSendEmailFile"

Is the script "SendEmailFile(FilePathSent)" not right?

Before making the sequence above, I had tried the sequence below which worked fine, leading me to proceed above.

\\ SendEmailWithFile

email.strTo = "my@myhome.com"

email.strCC = "theboss@hishome.com"

email.strSubject = "Test email with a file/from DAQ"

email.strBody = "Test email with a file"

email.strFile = "C:\aa onlinesoft\datalogger\log2.xlsx"

email.send()

Thanks in advance.

Link to comment
Share on other sites

Line 2 of your sequence is the function declaration line. I don't see anything wrong with it, and in fact, I created a sequence called SendEmailFile and posted your script and it worked just fine, so likely there is a typo somewhere that is not coming through by your posting. In general this is why I recommend posting your .ctl, as then I can see if the problem is coming from elsewhere.

Link to comment
Share on other sites

The sequence below "SendEmailFile" now began to work fine after correcting the name of the sequence.

(I found that the name should be nothing but "SendEmailFile"!)

// function SendEmailFile

function SendEmailFile(string FilePathSent)

email.strTo = "09092414228@i.softbank.jp"

email.strCC = "asaikk@suisui.ne.jp"

email.strSubject = "File delivery/from DAQ"

email.strBody = "Please find the attached file"

email.strFile = FilePathSent

email.Send()

But then the sequence below to trigger the "SendEmailFile" has a problem, having an error message;

"C1008 Could not send message! Response: 354 Ok Send data ending with <CRLF>.<CRLF>"

// Check2 Trigger function SendEmailFile

while(1)

SendEmailFile("C:\aa onlinesoft\datalogger\log\MyLog_120229_2034.csv")

delay(60)

endwhile

Could you give me the explanation of the the message?

I post the ctl file.

Thank you in advance.

test_FunctionSendEmailLogFile.ctl

Link to comment
Share on other sites

Any email error messages that have "Response:" in it, mean that DF communicated with the server, but the server sent back an error. In this case, the error code is 354, and the message from the server is "Ok Send data ending with <CRLF>.<CRLF>" From here you have to search the internet to figure out why your server doesn't like the incoming email. A very quick glance tells me that your server may be checking the reply to address and rejecting the email because it doesn't exist, or doesn't match the account.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.