GrapeCity Secure Mail for .NET 4.0J
Unsubscribe メソッド
使用例 

メールボックスの購読を停止します。
シンタックス
Public Function Unsubscribe() As ImapResponse
public ImapResponse Unsubscribe()

戻り値の型

サーバーからの応答をカプセル化するImapResponseオブジェクト。
例外
例外解説
ProtocolExceptionサーバーから受信したIMAPプロトコル応答が不良です。
System.Net.Sockets.SocketException通信エラーが発生しました。
解説

このメソッドはUNSUBSCRIBEコマンドをサーバーに送信し、このメールボックスをユーザーの購読メールボックスのセットから削除します。

購読しているメールボックスのリストを取得するには、次のコードを使用します。

Imap.List("", "%", true);
使用例
以下のサンプルコードは、メールボックスを作成、名前変更、および削除する方法を示します。また、メールボックスの購読を開始および停止する方法も示します。
private void doMailboxFunctions(object sender)
{
    // サーバーとアカウントの情報を設定します。
    imap1.Session.RemoteEndPoint = new Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session));
    imap1.Session.Username = myUsername;
    imap1.Session.Password = myPassword;

    // 接続してアカウントにログインします。
    imap1.Connect();
    imap1.Authenticate();

    // メールボックスを作成します。
    Mailbox newBox = imap1.Mailboxes.Add("My_New_Box");

    // メールボックスの購読を開始し、購読リストをチェックします。
    newBox.Subscribe();
    // 購読しているすべてのメールボックスを取得します。
    List<Mailbox> list = imap1.List("", "%", true).ToList<Mailbox>();
    if (!list.Contains(newBox)) throw new Exception("Server did not subscribe the mailbox.");

    // メールボックスの購読を停止し、購読リストをチェックします。
    newBox.Unsubscribe();
    list = imap1.List("", "%", true).ToList<Mailbox>();
    if (list.Contains(newBox)) throw new Exception("Server did not unsubscribe the mailbox.");

    // メールボックスの名前を変更してから、メールボックスを削除します。
    newBox.Name = newBox.Name + "_Renamed";
    imap1.Mailboxes.Remove(newBox);

    // セッションから適切にログアウトします。
    imap1.Close();
}
Private Sub doMailboxFunctions(ByVal sender As Object)
    ' サーバーとアカウントの情報を設定します。
    imap1.Session.RemoteEndPoint = New Dart.Mail.IPEndPoint(myServer, Imap.GetDefaultPort(imap1.Session))
    imap1.Session.Username = myUsername
    imap1.Session.Password = myPassword

    ' 接続してアカウントにログインします。
    imap1.Connect()
    imap1.Authenticate()

    ' メールボックスを作成します。
    Dim newBox As Mailbox = imap1.Mailboxes.Add("My_New_Box")

    ' メールボックスの購読を開始し、購読リストをチェックします。
    newBox.Subscribe()
    ' 購読しているすべてのメールボックスを取得します。
    Dim list As List(Of Mailbox) = imap1.List("", "%", True).ToList()
    If Not list.Contains(newBox) Then
        Throw New Exception("Server did not subscribe the mailbox.")
    End If

    ' メールボックスの購読を停止し、購読リストをチェックします。
    newBox.Unsubscribe()
    list = imap1.List("", "%", True).ToList()
    If list.Contains(newBox) Then
        Throw New Exception("Server did not unsubscribe the mailbox.")
    End If

    ' メールボックスの名前を変更してから、メールボックスを削除します。
    newBox.Name = newBox.Name & "_Renamed"
    imap1.Mailboxes.Remove(newBox)

    ' セッションから適切にログアウトします。
    imap1.Close()
End Sub
参照

参照

Mailbox クラス
Mailbox メンバ

 

 


© 2003, GrapeCity inc. All rights reserved.