MBS Plugin Documentation

Search:

Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchie

New in Version 7.0 7.1 7.2 7.3 7.4 7.5 7.6 7.7 7.8 8.0 8.1 8.2 8.3 8.4 8.5 8.6 8.7 9.0

The list of the   themes,   classes,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

FAQ.How do I decode correctly an email subject?
Feedback.

Answer: The following code can be used to decode an email subject including several encodings including Base 64.
Example:
Function DecodeEmailHeader(src as string) As String

dim theRegex as Regex
dim theRegexMatch as RegexMatch
dim result, infoCharset, encodedPart as string
dim theStart as integer

if instr(src, "=?") > 0 then
theRegex = new Regex
theRegex.Options.Greedy = false
theRegex.searchPattern = "(.*)=\?(.+)\?(Q|B)\?(.+)\?="
theRegexMatch = theRegex.search(src)
while theRegexMatch <> nil
theStart = theRegexMatch.subExpressionStartB(0) + len(theRegexMatch.subExpressionString(0))

result = result + theRegexMatch.subExpressionString(1)
infoCharset = theRegexMatch.subExpressionString(2)
encodedPart = theRegexMatch.subExpressionString(4)
if theRegexMatch.subExpressionString(3) = "B" then
encodedPart = DecodeBase64(encodedPart)
elseif theRegexMatch.subExpressionString(3) = "Q" then
encodedPart = DecodeQuotedPrintable(encodedPart)
end if
if right(result, 1) = " " then
result = mid(result, 1, len(result)-1)
end if
encodedPart = encodedPart.DefineEncoding(GetInternetTextEncoding(infoCharset))
result = result + encodedPart

theRegex.SearchStartPosition = theStart
theRegexMatch = theRegex.search()
wend

result = result + mid(src, theStart+1)

else
result = src
end if
// theRegexMatch = theRegex.search

return result
End Function

Notes: May not look nice depending on the controls used.