4

TestCompleteを使用して受信トレイのメールに返信する簡単な方法を見つけるのに苦労しています。

現在、私はそのためのコードを使用しています。ここhttp://support.smartbear.com/viewarticle/9022/のJScriptセクションにあります。

返信をシミュレートするために、本文と件名に基づいて電子メールを作成して送信することができました。ただし、これは十分ではありません。テストしているソフトウェアは、正しいユーザーのメールボックスに配置するために、以前に送信されたメッセージにリンクするための実際の応答が必要です。

どんな助けでも大歓迎です。さらに詳しい情報が必要な場合はお問い合わせください。

4

2 に答える 2

2

COM 経由で Outlook を使用する場合、問題なくこれを実行できるはずです。あなたが言及した記事のサンプルを変更して、これを行う方法を示しました。

function Test()
{
  Log.Message(replyToMessage2010("account name", "sender email", "Test 1234321", "This is a reply"));
}

function replyToMessage2010(accountName, senderEMail, eMailSubject, replyText)
{
  var OutlookApplication = Sys.OleObject("Outlook.Application"); 
  var NamespaceMAPI = OutlookApplication.GetNamespace("MAPI"); 

  // Check whether the specified account exists:
  if (NamespaceMAPI.Accounts.Item(accountName) != null)
  {
    NamespaceMAPI.SendAndReceive(false);

    // Get the "Inbox" folder
    var inbox = NamespaceMAPI.Folders(accountName).Folders("Inbox");
    var items = inbox.Items;
    for (var i = 1; i < items.Count + 1; i++)
    {
      if (items.Item(i).Subject == eMailSubject && 
        items.Item(i).SenderEmailAddress == senderEMail && items.Item(i).UnRead)
      {
        var reply = items.Item(i).ReplyAll();
        reply.Body = replyText + reply.Body;
        reply.Send(); 
        return true;
      }   
    }
    return false;
  } else
  {
    OutlookApplication.Quit();
    return false;
  }
}
于 2012-10-24T08:44:18.997 に答える
0

私は答えを見つけました。MailItem.Reply() メソッドがメールを送信すると思っていたのは、かなりばかげていました。ただし、MailItem.Send() で明示的に送信する必要があることがわかりました。

これが私のコードです:

//Creates a reply MailItem
var replyEmail = currentEmail.Reply();
//Creates a variable on the reply email's body
var body = replyEmail.Body; 
//Additional text to add
var additionaltext = "Reply to Email Message.\n"; 
//Start position for insert
var startpos = 0; 
//Inserts additional text to the beginning of the message
var fullBody = aqString["Insert"](body, additionaltext, startpos);
//Applies the new body to the reply email
replyEmail.Body = fullBody;
//Sends the new reply
replyEmail.Send();

新しいボディを持つ理由は、それ以外の場合は空白の応答が送信されるためです。

于 2012-10-24T08:37:30.770 に答える