Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
There are times when you may want to enumerate the fields set on a message while debugging issues with CDOSYS, System.Web.Mail, or System.Net.Mail. Below is sample code which will enumerate these fields. As you can see, there are some considerable differenences between how enumeration is done.
CDOSYS:
-------
int iCount = 0;
for (iCount = 0; iCount < oMsg.Fields.Count; iCount++)
{
if (oMsg.Fields[iCount] != null)
{
if (oMsg.Fields[iCount].Value != null)
Console.WriteLine(iCount.ToString() + " " + oMsg.Fields[iCount].Name + ": " + oMsg.Fields[iCount].Value.ToString());
else
Console.WriteLine(iCount.ToString() + " " + oMsg.Fields[iCount].Name + ": " + "<null>");
}
else
{
Console.WriteLine(iCount.ToString() + " " + "Null Field");
}
}
System.Web.Mail:
----------------
using System.Collections;
. . .
IDictionaryEnumerator e = (IDictionaryEnumerator)oMsg.Fields.Keys.GetEnumerator();
while (e.MoveNext())
{
if (e.Value != null)
Console.WriteLine(e.Key + ": " + e.Value.ToString());
else
Console.WriteLine(e.Key + ": " + "<null>");
}
System.Net.Mail
----------------
string[] sKeys = oMsg.Headers.AllKeys;
foreach (string sKey in sKeys)
{
if (oMsg.Headers[sKey] != null)
Console.WriteLine(sKey + ": " + oMsg.Headers[sKey]);
else
Console.WriteLine(sKey + ": " + "<null>");
}
Comments
- Anonymous
August 14, 2008
PingBack from http://housesfunnywallpaper.cn/?p=736