1

我的 Access (2003) 数据库中有一个备注字段,用于存储 Outlook 中文件夹的 EntryID(大约 750 个字符)。我正在尝试取回该字符串以使用以下代码将一些邮件移动到该文件夹​​ ID:

Dim myNameSpace As Outlook.NameSpace
Dim StoreID As String
Dim target as String 'This is the long EntryID string
Dim objMail as mailitem 'some mail

Set myNameSpace = Application.GetNamespace("MAPI")
StoreID = Application.GetNamespace("MAPI").folders("LiveLink").StoreID
Set dossier = myNameSpace.GetFolderFromID(target, StoreID)
objMail.Move dossier

在这种target情况下,var 只有前 252 个字符而不是 748 个字符。有趣的是,如果没有其他可用的具有相同 ~255 个首字符的文件夹,Outlook 仍然会找到正确的文件夹。但在某些情况下,它会因为不止一个而崩溃。我正在使用Recordset从数据库中获取备忘录。这是我的 SQL:

SELECT EntryID FROM Folder

我终于找到了关于这种行为的一些信息:http: //allenbrowne.com/ser-63.html。但是,如您所见,我没有在查询中使用任何联合或任何特定内容...

为什么它仍然被截断?

数据库中的原始备忘录/字符串:

00000000CE5B922DF5D7654C993FFDB4FF79A7A00100000057010000307E7E2D317E305C307E4C6976656C696E6B204851457E307E2D315C307E4C6976656C696E6B204851457E2D357E305C307E4C6976656C696E6B204851457E313233373235387E2D355C307E4C6976656C696E6B204851457E31303233363334317E313233373235385C307E4C6976656C696E6B204851457E31323930393430387E31303233363334315C307E4C6976656C696E6B204851457E31343539333439307E31323930393430385C307E4C6976656C696E6B204851457E31383735353632377E31343539333439305C307E4C6976656C696E6B204851457E3131363434333236317E31383735353632375C307E4C6976656C696E6B204851457E3131363434333236347E3131363434333236315C307E4C6976656C696E6B204851457E3131363434333238397E3131363434333236345C307E4C6976656C696E6B204851457E3131363434333330337E313136343433323839

SQL 查询后截断的备忘录/对象/字段/字符串:

00000000CE5B922DF5D7654C993FFDB4FF79A7A00100000057010000307E7E2D317E305C307E4C6976656C696E6B204851457E307E2D315C307E4C6976656C696E6B204851457E2D357E305C307E4C6976656C696E6B204851457E313233373235387E2D355C307E4C6976656C696E6B204851457E3130323336333431

4

2 回答 2

1

如您的链接所示,这应该有效

Set rs = CurrentDb.Execute("SELECT Mid(EntryID,  1,250)  AS part1, " & _
       " Mid(EntryID,251,250)  AS part2," & _
       " Mid(EntryID,501,250)  AS part3," & _
       " Mid(EntryID,751,250)  AS part4," & _
       " Mid(EntryID,1001,250) AS part5 " & _
                          " FROM Folder;")
target = rs("part1") & rs("part2") & rs("part3") & rs("part4") & rs("part5")
于 2012-10-12T15:10:19.677 回答
0

我已经实现了这个 c# 代码:

  private string GetMemoField(string TableName, string FieldName, string IdentityFieldName, string IdentityFieldValue, OleDbConnection conn)
    {
        string ret = "";

        OleDbCommand cmd1 = new OleDbCommand("SELECT " + FieldName + " FROM “ + TableName + “ WHERE " + IdentityFieldName + "=" + IdentityFieldValue, conn);

                var reader = cmd1.ExecuteReader(System.Data.CommandBehavior.SequentialAccess);  // Create the DataReader that will get the memo field one buffer at a time

        if (reader.Read())
        {
            long numberOfChars = reader.GetChars(/*Field pos*/ 0, 0, null, 0, 0);   // Total number of memo field's chars

            if (numberOfChars > 0)
            {
                int bufferSize = 1024;
                char[] totalBuffer = new char[64*bufferSize];    // Array to hold memo field content

                long dataIndex = 0;

                do
                {

                    char[] buffer = new char[bufferSize];   // Buffer to hold single read
                    long numberOfCharsReaded = reader.GetChars(0, dataIndex, buffer, 0, bufferSize);

                    if (numberOfCharsReaded == 0)
                    {
                        ret = new string(totalBuffer,0, (int)numberOfChars);
                        break;
                    }

                    Array.Copy(buffer, 0, totalBuffer, dataIndex, numberOfCharsReaded);     // Add temporary buffer to main buffer
                    dataIndex += numberOfCharsReaded;

                } while (true);
            }
        }

        return ret;
    }
于 2015-08-24T16:50:18.943 回答