SMMsg suite: how to create the .eml file from code

I created the new sample project where I shown how you may create the .eml file from your code using SMMsg suite:

uses SMMsg, SMMSGTags;
 
procedure TfrmMain.btnCreateEMLClick(Sender: TObject);
var
  eml: TSMEMLFile;
begin
  eml := TSMEMLFile.Create(Self);
  try
    eml.Properties.AddTypedValue(PR_SENT_REPRESENTING_EMAIL_ADDRESS, '[email protected]');
    eml.Properties.AddTypedValue(PR_RCVD_REPRESENTING_EMAIL_ADDRESS, '[email protected]');
    eml.Properties.AddTypedValue(PR_CLIENT_SUBMIT_TIME, Now());
//    eml.Properties.AddTypedValue(PR_MESSAGE_CODEPAGE, 1251);
    eml.Properties.AddTypedValue(PR_SUBJECT, 'Subject');
 
    eml.Properties.AddTypedValue(PR_BODY,
               'Hello,'#13#10+
               #13#10+
               'you may visit our site http://www.scalabium.com'#13#10+
               'or contact by email [email protected]'#13#10+
               #13#10+
               'With best regards, Mike Shkolnik');
 
    eml.Properties.AddTypedValue(PR_BODY_HTML,
               '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">'#13#10+
               '<HTML><HEAD>'#13#10+
               '</HEAD>'#13#10+
               '<BODY>'#13#10+
               '<p>Hello,</p>'#13#10+
               '<p>you may visit our site <a href="http://www.scalabium.com">http://www.scalabium.com</a><br>'#13#10+
               'or contact by email <a href="mailto:[email protected]">[email protected]</a></p>'#13#10+
               '<p>With best regards, Mike Shkolnik</p>'#13#10+
               '</BODY></HTML>');
 
    eml.Properties.AddAttachmentFile(ExtractFilePath(Application.ExeName) + 'scalfaq.gif');
 
    eml.SaveToEMLFile(ExtractFilePath(Application.ExeName) + 'test.eml', True)
  finally
    eml.Free
  end;
 
  ShowMessage('File ' + ExtractFilePath(Application.ExeName) + 'test.eml' + ' created succesfully');
end;

Tags:

Comments are closed.