Use SSL with Delphi yet still having a single exe

2019-03-15 23:35发布

We use Indy and we need SSL eMail support in our app., however we need to have our application in a single .Exe.

We know that the default Indy handler requires to have the dlls in the path. Extracting the Dlls from one of the EXE's resources would be the last resort.

Any better ideas?

8条回答
【Aperson】
2楼-- · 2019-03-16 00:11

TOndrey gave you a good answer. I use SecureBlackBox as well. You may consider some other third party components:

查看更多
一夜七次
3楼-- · 2019-03-16 00:11

Const

  cdoSendUsingMethod = 'http://schemas.microsoft.com/cdo/configuration/sendusing';  
  cdoSMTPServer = 'http://schemas.microsoft.com/cdo/configuration/smtpserver';  
  cdoSMTPServerPort = 'http://schemas.microsoft.com/cdo/configuration/smtpserverport';  
  cdoSendServerPort = '25';  
  cdoSendUsingPort = 2;  
  cdoSMTPConnectionTimeout = 'http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout';  
  cdoSMTPAuthenticate = 'http://schemas.microsoft.com/cdo/configuration/smtpauthenticate';  
  cdoAnonymous = '0';  
  cdoBasic = '1';  
  cdoSMTPUseSSL = 'http://schemas.microsoft.com/cdo/configuration/smtpusessl';  
  cdoSendUserName = 'http://schemas.microsoft.com/cdo/configuration/sendusername';  
  cdoSendPassword = 'http://schemas.microsoft.com/cdo/configuration/sendpassword';  
  cdoURLGetLatestVersion = 'http://schemas.microsoft.com/cdo/configuration/urlgetlatestversion';  

...

function SensCDOMail (ASubject, AFrom, ATo, ABody, ASmtpServer : WideString): String;  
var 

  cdoMessage:OleVariant;  
  cdoConfiguration: OleVariant;  

begin  

  //Configuration Object  
  cdoMessage:= CreateOleObject('CDO.Message');  
  cdoConfiguration:= CreateOleObject('CDO.Configuration');  
  try  

    cdoConfiguration.Fields(cdoSendUsingMethod):= cdoSendUsingPort;  
    cdoConfiguration.Fields(cdoSMTPServer):= ASmtpServer;  
    cdoConfiguration.Fields(cdoSMTPServerPort):= cdoSendServerPort;  
    cdoConfiguration.Fields(cdoSMTPAuthenticate):= cdoAnonymous;  
    cdoConfiguration.Fields(cdoSMTPUseSSL ):= True; // use SSL  
    cdoConfiguration.Fields.Update;  
    cdoMessage.Configuration:= cdoConfiguration;  
    cdoMessage.To       := ATo;
    cdoMessage.From     := AFrom;
    cdoMessage.Subject  := ASubject;
    //cdoMessage.HTMLBody := ABody;   //Want to send in Html format
    cdoMessage.TextBody := ABody;     //Want to send in text format
    cdoMessage.Send;

  finally  
    VarClear(cdoMessage);  
    VarClear(cdoConfiguration);  
  end;  
end;  

查看更多
登录 后发表回答