電子郵件帳號中憑證寫入的問題 |
缺席
|
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
|
pgdennis
資深會員 發表:41 回覆:526 積分:443 註冊:2002-05-23 發送簡訊給我 |
1.使用元件的方式可以,我試了網路上找到的元件,你可參考
http://www.chilkatsoft.com/chilkatCertRef.asp#certProp,在download頁中請下載Chilkat Mail ActiveX及FREE Certificate ActiveX兩個元件,並安裝.
2.安裝好後,才會有delphi需要的type lib檔,他網站是的範例是用VB的,我改寫成delphi了,可以work.你可以先下載其他範例 class="code">unit Unit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, CHILKATCERTIFICATELib_TLB, OleCtrls,
CHILKATMAILLib_TLB; type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
ChilkatMailMan1: TChilkatMailMan;
ChilkatCreateCS1: TChilkatCreateCS;
Memo1: TMemo;
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} procedure TForm1.BitBtn1Click(Sender: TObject);
var
email:ChilkatEmail;
EmailF:TEmailFactory;
ChilkatCert1:ChilkatCert;
success:longint;
begin //' Find the certificate that we will use to sign the email.
// ChilkatCreateCS1 is a ChilkatCreateCS object that has been
// dropped onto the Visual Basic form.
//find的方法有很多,我是用serial number,這個你可以跑show list的範例就可以知道了,網站上有,vb寫的
ChilkatCert1:=(ChilkatCreateCS1.OpenCurrentUserStore as IChilkatCertStore).FindCertBySerial('3e77b70b'); // We could've loaded the certificate from a DER encoded X.509 .cer file.
//Set cert = New ChilkatCert
//cert.LoadFromFile "matt.cer"
// Get an evaluation unlock-code from http://www.chilkatsoft.com/register30.asp
ChilkatMailMan1.UnlockComponent('UnlockCode'); // Set our SMTP server to be used for sending signed mail.
ChilkatMailMan1.SmtpHost := 'tchsmtp1.aidc.com.tw';
// Only set username/password if your SMTP server requires a logon.
//mailman.SmtpUsername = "your_username"
//mailman.SmtpPassword = "your_password"
// Only set the login domain if your SMTP server uses integrated Windows authorization
// AND it is part of a domain.
//mailman.SmtpLoginDomain = "your_domain" // Assign the cert to the email so that it is used when signing the email.
EmailF:=TEmailFactory.Create(application);
email:=EmailF.NewEmail;
email.SetSigningCert(CHILKATMAILLib_TLB.IChilkatCert(ChilkatCert1)); email.AddTo ('Email Expert', 'chiahaodai@ms.aidc.com.tw');
email.Subject := 'This is the subject';
email.Body := 'This is the body';
email.From := 'matt@chilkatsoft.com'; // Indicate that the email should be sent digitally signed.
// When sending a signed email, the private key is used, so the private key
// associated with the chosen certificate must be installed on the system.
email.SendSigned := 1;
// Send mail. Returns 1 for success, 0 for failure
success := ChilkatMailMan1.SendEmail(email); // Display the details of the certificate used in signing.
memo1.Lines.Add('Sent signed email with certificate');
memo1.Lines.add('certificate serial number: ' chilkatCert1.SerialNumber);
memo1.Lines.add('certificate subject common name:' ChilkatCert1.SubjectCN );
memo1.Lines.add('certificate subject email: ' ChilkatCert1.SubjectE );
// Save the log regardless of success/failure
ChilkatMailMan1.SaveXmlLog('log.xml');
end; end.
永遠追不上技術更新的速度
------
星期一,二...無窮迴圈@@ |
kaija
一般會員 發表:16 回覆:14 積分:6 註冊:2003-07-24 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |