小编use*_*415的帖子

尝试使用 Exchange Web 服务获取电子邮件时出现 ServiceObjectPropertyException?

我正在尝试获取未读电子邮件,然后将其标记为已读。

当我运行代码时出现此异常:

ServiceObjectPropertyException 未处理:

Microsoft.Exchange.WebServices.dll 中发生类型为“Microsoft.Exchange.WebServices.Data.ServiceObjectPropertyException”的未处理异常

当我尝试将 Exchange 邮件对象映射到业务模型对象时发生此错误。

这是映射方法:

class MailMapper
{
     public static PhishingMail Map(EmailMessage OutlookMail)
     {
          //Map Exchange email object op Business model email object
          PhishingMail readMail = new PhishingMail();
          readMail.Subject = OutlookMail.Subject;
          return readMail;
      }
}
Run Code Online (Sandbox Code Playgroud)

这是应该将电子邮件标记为已读的代码。

public List<PhishingMail> GetEmails() 
{
    phishingMailList = new List<PhishingMail>();

    FolderId InboxId = new FolderId(WellKnownFolderName.Inbox, "A*******m@i*****nl");

    FindItemsResults<Item> findResults = service.FindItems(InboxId, new ItemView(100));

    foreach (Item phishingmail in findResults.Items)
    {
        ((EmailMessage)phishingmail).Load(new PropertySet(BasePropertySet.IdOnly, EmailMessageSchema.IsRead)); 

        if (!((EmailMessage)phishingmail).IsRead) 
        {
            ((EmailMessage)phishingmail).IsRead = true;
            ((EmailMessage)phishingmail)
                .Update(ConflictResolutionMode.AutoResolve);
        }

        PhishingMail …
Run Code Online (Sandbox Code Playgroud)

c# exchangewebservices

4
推荐指数
1
解决办法
3585
查看次数

找不到源类型的查询模式的实现

我正在尝试打印并获取一行数字(2,4,8,16,32,但)然后应该大于10但小于1000使用LINQ表达式.我不知道我做错了什么.

当我使用时,我的program.cs中出现错误,它强调了r.我不明白这个错误意味着什么.

Program.cs中:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

 namespace _3._4
 {
    class Program
{
    static void Main(string[] args)
    {
        Reeks r = new Reeks();

      var query =
                     from i in r// error is here
                     where i > 10 && i < 1000
                     select 2 * i;

        foreach (int j in query)
        {

            Console.Write(j);


        }
    }
}
Run Code Online (Sandbox Code Playgroud)

}

Reeks.cs:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _3._4
 {
    class Reeks : IEnumerable
{
    private …
Run Code Online (Sandbox Code Playgroud)

c# linq ienumerable

3
推荐指数
1
解决办法
2323
查看次数

无法将类型“void”隐式转换为“int”?

好的,所以我对编程还很陌生,我不明白为什么会出现此错误。

我的方法应该存储它在这个方法中所做的邮件:

    public void StoreMail(PhishingMail PhishingMail)
    {
        using (var phishingMailStorage = new PhishFinderModel())
        {
            phishingMailStorage.PhishingMail.Attach(PhishingMail);

            phishingMailStorage.SaveChanges();

        }
Run Code Online (Sandbox Code Playgroud)

然后在我的 processPhishingMail 方法中,它调用 Store 方法。但是后来我收到错误:无法将类型“void”隐式转换为“int”。

public void ProcessPhishingMail(PhishingMail phishingMail)
{                     
      Hashtable phishingUrls;
      int phishingMailId;
      int phishingUrlId;
      //Error convertion
      phishingMailId = _storageAgent.StoreMail(phishingMail);
Run Code Online (Sandbox Code Playgroud)

所以我真的找不到从void转换为int的解决方案。也许这是不可能的?

我的问题是:如何在我的代码中转换这些类型?

请不要苛刻我真的很陌生。感觉就像我在信息的海洋中游泳,我不知道从哪里看或从哪里开始。因此,非常欢迎任何建议的教程。

c# int entity-framework void

1
推荐指数
1
解决办法
2万
查看次数