0

私は5日から問題で立ち往生しています。

次の要件を満たす方法が必要です。

  1. メーリングリストはデータベース(SQLサーバー)に存在します
  2. Outlookにメールがあります
  3. 今、私はデータベース内のすべての200,000メールIDにメールを送信する必要があります
    ** 1つのメールは200メールIDしか持てないため、200,000 / 200 = 1000メール**注:この200,000カウントは固定されておらず、減少および増加します> jhon @ xyz.comは今日存在します。翌日、彼に名前を送信する必要がない場合があります。彼の名前は完全に削除される可能性があります(したがって、DLはオプションではありません)。
  4. これを自動化する方法が必要です
  5. すべての私は私の机の上に睡眠が少ない夜とコーヒーカップを持っています

私はASP.netで作業しており、このニーズを満たすPLであれば問題ありません。

4

1 に答える 1

0

必要なSQLステートメントを作成する方法と.NETのデータベースからデータを取得する方法を知っていると思います。これは、問題が実際にこれをOutlookから送信していることだけを意味します。

これを詳細に説明する記事と、そこからコピーされたコードを次に示します

using System; 
using System.Text; 
using Outlook = Microsoft.Office.Interop.Outlook; 

namespace OutlookAddIn1 
{ 
    class Sample 
    { 
        public static void SendEmailFromAccount(Outlook.Application application, string subject, string body, string to, string smtpAddress) 
        { 

            // Create a new MailItem and set the To, Subject, and Body properties. 
            Outlook.MailItem newMail = (Outlook.MailItem)application.CreateItem(Outlook.OlItemType.olMailItem); 
            newMail.To = to; 
            newMail.Subject = subject; 
            newMail.Body = body; 

            // Retrieve the account that has the specific SMTP address. 
        Outlook.Account account = GetAccountForEmailAddress(application, smtpAddress); 
            // Use this account to send the e-mail. 
            newMail.SendUsingAccount = account; 
            newMail.Send(); 
        } 


        public static Outlook.Account GetAccountForEmailAddress(Outlook.Application application, string smtpAddress) 
        { 

            // Loop over the Accounts collection of the current Outlook session. 
            Outlook.Accounts accounts = application.Session.Accounts; 
        foreach (Outlook.Account account in accounts) 
            { 
                // When the e-mail address matches, return the account. 
                if (account.SmtpAddress == smtpAddress) 
                { 
                    return account; 
                } 
            } 
            throw new System.Exception(string.Format("No Account with SmtpAddress: {0} exists!", smtpAddress)); 
        } 

   } 
}

私が提案するのは、本当に必要な場合を除いてOutlookの使用をスキップし、SMTPサーバーと直接通信して電子メールを送信することです。

「C#からメールを送信する方法」などを検索するだけで、たくさんの例が見つかります。

于 2013-04-17T17:36:59.437 に答える