Delphi DLL Requires Chilkat v11.0.0+
Delphi DLL
Find the text in an archived T-Mobile gateway email
See more Email Object Examples
Some archived gateway messages carry the SMS text as a related MIME item. Check for an ordinary text body first, then inspect related items by media type. The related-text branch assumes UTF-8, as in the sample format. It reads a saved email and needs no carrier service.
Chilkat Delphi DLL Downloads
var
success: Boolean;
email: HCkEmail;
mediaType: HCkStringBuilder;
i: Integer;
begin
success := False;
// Assumes Chilkat is unlocked. See Global Unlock Sample.
email := CkEmail_Create();
success := CkEmail_LoadEml(email,'gateway.eml');
if (success <> True) then
begin
Memo1.Lines.Add(CkEmail__lastErrorText(email));
Exit;
end;
if (CkEmail_HasPlainTextBody(email) = True) then
begin
Memo1.Lines.Add(CkEmail__getPlainTextBody(email));
Exit;
end;
mediaType := CkStringBuilder_Create();
i := 0;
while (i < CkEmail_getNumRelatedItems(email)) do
begin
CkStringBuilder_SetString(mediaType,CkEmail__getRelatedContentType(email,i));
if (CkStringBuilder_ContentsEqual(mediaType,'text/plain',False) = True) then
begin
Memo1.Lines.Add(CkEmail__getRelatedString(email,i,'utf-8'));
Exit;
end;
i := i + 1;
end;
Memo1.Lines.Add('No text body or related text/plain part.');
CkEmail_Dispose(email);
CkStringBuilder_Dispose(mediaType);