Convert message with text attachment
Posted: 2019-10-01 02:14
I need to convert email received from several SMS gateways into more convenient format. I know I can select these messages for processing using a rule, and handle the processing using a script, but I am soliciting advice for the most efficient way to process the conversion.
Reviewing the headers of these messages, the text of the SMS appears as plain text immediately after the blank line delimiting the message body from the headers.
The header section include these lines:
In Outlook, these messages appear with an empty body and a single text file attachment named text_0.txt. The message text is contained in the text file.
The hMailServer API doesn't provide a way to access an attachment's contents directly, so I'd have to save the attachment to a temporary file, read the contents, append that text to the Message.Body, and delete the temporary file. Seems like an inelegant way to handle the conversion.
I'd prefer to read the attachment text directly from the message content but I don't see a method or property that gives me access all sections of the message as string data without reading the message file from disk.
Any other ideas?
Reviewing the headers of these messages, the text of the SMS appears as plain text immediately after the blank line delimiting the message body from the headers.
The header section include these lines:
Code: Select all
Content-Type: text/plain;
name="text_0.txt"
Content-Transfer-Encoding: 7bit
Content-ID: <0>
Content-Disposition: attachment;
filename="text_0.txt"
The hMailServer API doesn't provide a way to access an attachment's contents directly, so I'd have to save the attachment to a temporary file, read the contents, append that text to the Message.Body, and delete the temporary file. Seems like an inelegant way to handle the conversion.
I'd prefer to read the attachment text directly from the message content but I don't see a method or property that gives me access all sections of the message as string data without reading the message file from disk.
Any other ideas?