HeaderItem.SubValue Method


Gets the value of the sub-key of the header.

[Visual Basic]
Public Function SubValue( _
    subKey As String _
) As String
[C#]
public string SubValue(
    string subKey
);
[C++]
public: String^ SubValue(
    String^ subKey
);
[JScript]
public function SubValue( 
    subKey : String
) : String;

Parameters

subKey
The sub-key name.

Return Value

The value of the sub-key.

Example

[Visual Basic] To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic - Parse Sub-Value]
Imports EAGetMail
Public Sub ParseHeaders()
    Dim oMail As New Mail("TryIt")
    oMail.Load("c:\test.eml", False)
    Dim oHeaders As HeaderCollection = oMail.Headers
    Dim count As Integer = oHeaders.Count
    For i As Integer = 0 To count - 1
        Dim oHeader As HeaderItem = oHeaders(i)
        Console.WriteLine("{0}: {1}", oHeader.HeaderKey, oHeader.HeaderValue)

        If String.Compare(oHeader.HeaderKey, "Content-Type", True) = 0 Then
            'if the header is: 
            'Content-Type: multipart/alternative;
            '   boundary = "=_MAILER_ATTACH_BOUNDARY1_200675313102924710512"
            ' then oHeader.SubValue("boundary") returns =_MAILER_ATTACH_BOUNDARY1_200675313102924710512
            Console.WriteLine("{0}", oHeader.SubValue("boundary"))
        End If
    Next
End Sub

See Also

Mail.Headers Property

Online Tutorials

Parse Email in C#
Parse Email in VB
Parse Email in C++/CLI