2009-02-26 7 views
2

Redemption dll(http://www.dimastr.com/redemption/)を使用していて、メールボックスにアクセスするexeを作成しました。ログインユーザー以外のユーザーとRedemption(Outlook)を使用するとエラーが発生する

Windowsのスケジューラで、自分のユーザ名でexeを実行してもうまくいきます。メールが届きました(下記のコードを参照)。

スケジューラのrunasユーザー名を他のユーザーに変更してメールボックスプロファイルにアクセスしようとすると、エラーが発生します。 System.IO.FileLoadException

static void Main(string[] args) 
{ 

    System.Diagnostics.Debugger.Break(); 

    object oItems; 

    //string outLookUser = "My Profile Name"; 
    string outLookUser = "Other User Profile Name"; 

    string ToEmailAddress = "[email protected]"; 
    string FromEmailAddress = "[email protected]"; 
    string outLookServer = "exchangeServer.com"; 

    string sMessageBody = 
     "\n outLookUser: " + outLookUser + 
     "\n outLookServer: " + outLookServer + 
     "\n\n"; 

    RDOSession Session = null; 

    try 
    { 
     rdoDefaultFolders olFolderInbox = rdoDefaultFolders.olFolderInbox; 

     Session = new RDOSession(); 
     RDOFolder objFolder; 

     Session.LogonExchangeMailbox(outLookUser, outLookServer); 

     int mailboxCount = Session.Stores.Count; 
     string defaultStore = Session.Stores.DefaultStore.Name; 

     sMessageBody += 
     "\n mailboxCount: " + mailboxCount.ToString() + 
     "\n defaultStore: " + defaultStore + 
     "\n\n"; 


     //RDOStore rmpMetering = Session.Stores.GetSharedMailbox("Name of another mailbox"); 
     //objFolder = rmpMetering.GetDefaultFolder(olFolderInbox); 

     objFolder = Session.GetDefaultFolder(olFolderInbox); 

     oItems = objFolder.Items; 
     int totalcount = objFolder.Items.Count; 
     if (totalcount > 10) totalcount = 10; 

     for (int loopcounter = 1; loopcounter < totalcount; loopcounter++) 
     { 
      RDOMail oItem = objFolder.Items[loopcounter]; 

      string attachmentName = string.Empty; 
      foreach (RDOAttachment attachment in oItem.Attachments) 
      { 
       attachmentName += attachment.FileName + " "; 


       if (attachmentName.Trim() == "Data.csv") 
       { 
        attachment.SaveAsFile(@"C:\datafiles\" + attachmentName.Trim()); 

        foreach (RDOFolder archiveFolder in objFolder.Folders) 
        { 
         if (archiveFolder.Name == "DataFileArchive") 
         { 
          oItem.MarkRead(true); 
          oItem.Move(archiveFolder); 
         } 
        } 
       } 
      } 

      sMessageBody += oItem.Subject + " " + attachmentName + "\n"; 
      if ((oItem.UnRead)) 
      { 
       //Do whatever you need this for      
       //sMessageBody = oItem.Body; 
       //oItem.MarkRead(true); 
      } 
     } 

     System.Web.Mail.SmtpMail.Send(ToEmailAddress,FromEmailAddress 
      , "Data File Processing-" + DateTime.Now.ToString() 
      ,"" + sMessageBody); 

    } 
    catch (Exception ex) 
    { 
     Session = null; 

     System.Web.Mail.SmtpMail.Send(ToEmailAddress, FromEmailAddress, "Error", sMessageBody + " " + ex.Message); 

    } 
    finally 
    { 
     if ((Session != null)) 
     { 
      if (Session.LoggedOn) 
      { 
       Session.Logoff(); 
      } 
     } 
    } 

} 

私は私と一緒に別のマシンで同じexeファイルを実行しようと、私はこのエラーを取得するにはログイン、

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass 
embly 'Interop.Redemption, Version=4.7.0.0, Culture=neutral, PublicKeyToken=null 
' or one of its dependencies. The system cannot find the file specified. 
File name: 'Interop.Redemption, Version=4.7.0.0, Culture=neutral, PublicKeyToken 
=null' 
    at RPMDataFileProcessing.Program.Main(String[] args) 

は、誰もが私がやっている上の任意のアイデアを持っています間違って、この方法で償還を使うことができますか?

答えて

2

これは、あなたがあなたがログインしようとしているメールボックスに「フルメールボックス権限」を持っていることを保証することによって、最終的に機能します。

関連する問題