2011-10-05 64 views
0

目前,我有以下代碼:用Delphi的Outlook自動化 - 隊列

while not (sqlMailMergeData.Eof) do 
    begin 

    if sqlMailMergeData.FieldByName('Email').AsString <> '' then 
    begin 
    Inc(Count); 
    {Connect to Outlook} 
    MailItem := OpOutlook1.CreateMailItem; 
    MailItem.MsgTo := sqlMailMergeData.FieldByName('Email').AsString; 
    MailItem.Body := Form48.Memo1.Text; 
    MailItem.Subject := Form48.Edit3.Text; 
    MailItem.Send; 
    end; 

    Form34.sqlMailMergeData.next; 
    end; 

但是Outlook會提示您,讓曾經有5秒的延遲發送電子郵件。循環後發送覆蓋相同的MailItem。

MailItem.Save; 

將所有項目保存爲草稿而不提示。這不是一個壞的解決方案,可能是一個額外的功能,但需要更多的用戶輸入將項目移動到發件箱。

是否有每個郵件項目發送到發件箱的功能?或者我應該考慮創建一個包含所有電子郵件地址的字符串

MailItem.MsgTo := "[email protected]; [email protected]" 

感謝

回答

3

當與Outlook的工作,你可能會考慮使用Outlook贖回1,這樣就可以繞過安全提示,並從代碼直接發送郵件。

+0

感謝託拜厄斯,但我在尋找一種不需要額外組件的解決方案。也許Delph代碼中繞過這個安全特性的東西。 – notidaho

1

那麼你唯一要做什麼Redemption是引擎蓋下做的選擇 - 使用擴展MAPI。

0

這是對我工作的罰款代碼:

Outlook := CreateOleObject ('Outlook.Application'); 

    // Repet the code below for each mail: 
    OutlookMail := Outlook.CreateItem (olMailItem); // olMailItem = 0; 
    OutlookMail.Recipients.Add ('[email protected]').Resolve; 
    OutlookMail.Recipients.Add ('[email protected]').Resolve; 
    OutlookMail.Subject := Form48.Edit3.Text; 
    OutlookMail.Body := Form48.Memo1.Text; 
    OutlookMail.BodyFormat := olFormatHTML; 
    // OutlookMail.SendUsingAccount := OutlookAccount; // If you need to select the acount 
    OutlookMail.Send; 
+0

如果您安裝了最新的防病毒軟件,這將只在沒有提示的情況下運行。否則,提示仍會顯示。 –