Jump to content
Macro Express Forums

Error Messages Into Text Variable


Recommended Posts

Is there any way to capture an error message into a text variable, or otherwise act on it in the running of a macro.


Example: On occasion, the error message "E-Mail Send Error: Socket Error # 10060" is written to the ErrorLog, showing that an email message was not sent.


Is there a way that the error message to have the macro put this error message into a text variable so the macro would do something different upon the occurrence of this error message?


Any help is much appreciated. Thanks.

Link to comment
Share on other sites

If an error message is present as a result of an email message failing to send, I want the macro to try again at a later time to send the email message. It appears that email messages will fail to send for a variety of reasons -- slow internet connection, email server down or slow, and who knows what else. Most of the email error messages on the log start out with the text "E-Mail Send Error: ...".


The elegant solution would be a feature which is present in the "FTP Send File" command which is to have an option to save the result of the Email Send to a Text Variable. There is, however, no such feature in the "Email Send" command.


I think I have found what appears to be a workaround solution to this. Since I am running a daily default error log all the time, simply having the macro check the error log for a message would not work since once the error appeared, the macro would think that the error occurred each time the macro ran for the remainder of the day. I thought about parsing down the default error log so that it only checked the last few lines but since the error messages I occasionally got had different numbers of characters and different text, I was afraid I would miss an unexpected one.


So what I did was to create an alternate error log just for the portion of the macro in which the email message is to send, have the macro check to see if the alternate error log is created at all, and if it is, then to re-send the email at a later time as well as save the contents of the alternate error log to the daily default error log so I know what happened.


The portion of the macro looks like this:


If File Does Not Exist: "[EmailTrackingFile.txt]"

Delete File: "EmailError.txt"

Log Errors: "EmailError.txt"

E-Mail Send: Know Recipients, Text from File, No Attachments

If File Exists "EmailError.txt"

Variable Set String %T29% from File: "EmailError.txt"

Delete File: "[EmailTrackingFile.txt]"

Variable Set String %T25% "ERROR"

Log Message (%T29%) to Default Error Log


Clipboard Save Text: "[EmailTrackingFile.txt]"

Log Message (Successful Email Send) to Default Error Log




Thus, for several lines of the macro, the default error log is "turned off", since apparently starting the Log Errors to a specific file turns off the logging to the default file, and once information from that alternate log file is read, the default error log is turned back on.


Not as elegant as simply having a "result" message sent to a Text Variable by the Email Send command, but it appears to work.


I have requested via the ME Feature Request that a "result" message be added to the Email Send command which would eliminate the need to do this alternate error log procedure.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...