C#.NET
string server = "mail.example.jp";
int port = 110;
string userid = "userid";
string pass = "pass";
System.Net.IPAddress address = System.Net.Dns.GetHostByName(server).AddressList[0];
TKMP.Net.IPopLogon logon = new TKMP.Net.BasicPopLogon(userid , pass);
TKMP.Net.PopClient pop = new TKMP.Net.PopClient(logon , address , port);
if(!pop.Connect())
{
System.Windows.Forms.MessageBox.Show("接続失敗");
return ;
}
int mailcount = pop.MailDatas.Length;
System.Windows.Forms.MessageBox.Show("着信メールは " + mailcount.ToString() + " 件です");
pop.Close();
VB.NET
Dim server As String = "mail.example.jp"
Dim port As Integer = 110
Dim userid As String = "userid"
Dim pass As String = "pass"
Dim address As System.Net.IPAddress = System.Net.Dns.GetHostByName(server).AddressList(0)
Dim logon As New TKMP.Net.BasicPopLogon(userid, pass)
Dim pop As New TKMP.Net.PopClient(logon, address, port)
If Not pop.Connect() Then
System.Windows.Forms.MessageBox.Show("接続失敗")
Return
End If
Dim mailcount As Integer = pop.MailDatas.Length
System.Windows.Forms.MessageBox.Show(("着信メールは " + mailcount.ToString() + " 件です"))
pop.Close()
VB.NETのコードはC#.NETを元に「
C#.NET to VB.NET Translator」によって作成したものです
手順としては、TKMP.Net.PopClientクラスでサーバーへ接続後、MailDatasプロパティの配列の数を数えることになります。