Moderators: Eric, Tomas, robin, Michael
ReadEmail $From
SetHeader %Out "From:" $From
ReadEmail $t
AddStrings $From "John Doe <" $t ">"
SetHeader %Out "From:" $From
Set $filename $temppath
AddStrings $filename "poco_bPz2Cm4nVSQLsHx.eml"
AppendToFile False
SaveMessageToFile %message $filename
Wait 2
; ... later
AttachFile %Out $filename
MarkB wrote:Regarding the second issue, try this. Replace these lines from the "Vacation Message" script
- Code: Select all
ReadEmail $From
SetHeader %Out "From:" $From
with these
- Code: Select all
ReadEmail $t
AddStrings $From "John Doe <" $t ">"
SetHeader %Out "From:" $From
ReadBody $OldBody %message
MarkB wrote:Notice this line in the Vacation Message script:
- Code: Select all
ReadBody $OldBody %message
ReadBody extracts a plain-text version of the message body, stripped of HTML niceties.
You might experiment with replacing ReadBody there with ReadRawBody. Add $OldBody to the bottom of $NewBody. Then AssignStyledBody %Out $NewBody. I haven't tested any of that.
{ Initialize user settings: }
External $userfile1 "Create message template" "vacation.txt"
ReadHeader $Subject "Subject:" %message
CreateMessage %Out
SetHeader %Out "From:" "John Doe <jdoe@domain.invalid>"
SetHeader %Out "To:" somewhere@domain.local
Set $NewSubject "FW: "
AddStrings $NewSubject $Subject
SetHeader %Out "Subject:" $NewSubject
;OpenBody $NewBody $UserFile1
Set $NewBody "<p>This is sample reply text.</p>"
AppendBody $NewBody "<hr><hr>"
ReadRawBody $OldBody %message
AppendBody $NewBody $OldBody
AssignStyledBody %Out $NewBody
SaveMessage %Out "Out.mbx"
MarkB wrote:QuoteBody was the main problem. The following is your script with a little cleanup. But these replies are never going to look right, I'm afraid.
- Code: Select all
{ Initialize user settings: }
External $userfile1 "Create message template" "vacation.txt"
ReadHeader $Subject "Subject:" %message
CreateMessage %Out
SetHeader %Out "From:" "John Doe <jdoe@domain.invalid>"
SetHeader %Out "To:" somewhere@domain.local
Set $NewSubject "FW: "
AddStrings $NewSubject $Subject
SetHeader %Out "Subject:" $NewSubject
;OpenBody $NewBody $UserFile1
Set $NewBody "<p>This is sample reply text.</p>"
AppendBody $NewBody "<hr><hr>"
ReadRawBody $OldBody %message
AppendBody $NewBody $OldBody
AssignStyledBody %Out $NewBody
SaveMessage %Out "Out.mbx"
AppendBody $NewBody "<p> My Message Text </p>"
AddendBody $NewBody "<p>This email came from</p>"
AppendBody $NewBody $Address
This works well for me. So far,...
ReadHeader $Address "From:" %message
ExtractEmail $Address
{ ReadBody and HTML messages: ReadBody is supposed to remove HTML tags and
{ return the text. It has two egregious flaws in this regard (v4.8.0.4400).
{ (1) It does not always strip the HTML tags: it does when Content-Type is
{ text/html; it does not when Content-Type is multipart/related.
{ (2) It sometimes strips text as well as tags (e.g., Google News Alerts).
{ The body ends with a CRLF (v4.8.0.4400).
{ Compose brief headers for the selected message.
{ Return result in the string $h.
{
{ ReadTo and ReadCC return addresses only, stripped of names (v4.8.0.4400):
{ who@zzzz.com vs. "Joe Who" <who@zzzz.com>
{ Therefore, the script reads To and CC headers with ReadHeader.
{
{ ReadHeader separates addresses with line breaks and inserts quotation marks
{ around names (v4.8.0.4400). (X-BCC headers do not contain names.)
{ In composing brief headers, the script removes those quotation marks and
{ joins addresses into a single line -- for legibility, for compactness, and
{ to conform to the familiar UI format.
{
IntToChar $qmark 34
ReadHeader $from "From:" %message
Set $h $from
Call StripQuotes
Set $from $h
ReadHeader $subject "Subject:" %message
ReadHeader $date "Date:" %message
ReadHeader $to "To:" %message
Set $h $to
Call JoinLines
Call StripQuotes
Set $to $h
ReadHeader $cc "CC:" %message
Set $h $cc
Call JoinLines
CallStripQuotes
Set $cc $h
Set $h "<p>----- Original Message -----<br>\n"
AddStrings $h "From: " $from "<br>\n"
AddStrings $h "Subject: " $subject "<br>\n"
AddStrings $h "Date: " $date "<br>\n"
AddStrings $h "To: " $to "<br>\n"
If $cc = "" Then SkipCC
AddStrings $h "CC: " $cc "<br>\n"
:SkipCC
AddStrings $h "</p>\n"
Exit
:JoinLines
{ Joins the lines in the string $h; separates items with a comma plus space.
{ Requires: $h
{ Changes: $h, $t, $jlLine, #jlMax, #jlIndex
{ Lines are indexed 0 to n-1
Set $t ""
LineCount #jlMax $h
Dec #jlMax
Set #jlIndex 0
:JoinLinesLoop
If #jlIndex > #jlMax Then EndJoinLinesLoop
GetLine $jlLine #jlIndex $h
If $jlLine = "" Then ContinueJoinLines
AddStrings $t $jlLine
If #jlIndex = #jlMax Then EndJoinLinesLoop
AddStrings $t ", "
:ContinueJoinLines
Inc #jlIndex
Goto JoinLinesLoop
:EndJoinLinesLoop
Set $h $t
Return
:StripQuotes
{ Removes double quotation marks (") from the string $h.
{ Requires: $h, $qmark
{ Changes: $h, #sqPos
StringPos #sqPos $qmark $h
If #sqPos < 1 Then Return
SubStrings $h $qmark
Goto StripQuotes
Return to PocoScript Help and How-To
Users browsing this forum: No registered users and 1 guest