Provides properties and methods for presenting an e-mail header.
IDispatch
IHeaderItem
[Visual Basic 6.0] Public Class HeaderItem
[Visual C++] public: interface IHeaderItem
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Public Properties
HeaderKey | Gets or sets the key of the header. |
HeaderValue | Gets or sets the value of the header. |
Public Methods
SubValue | Gets the value of the sub-key of the header. |
Example
[Visual Basic 6.0, VBScript, Visual C++, Delphi] To get the full samples of EAGetMail, please refer to Samples section.
[Visual Basic 6.0] Public Sub ParseHeaders() Dim oMail As New EAGetMailObjLib.Mail oMail.LicenseCode = "TryIt" oMail.LoadFile "c:\test.eml", False Dim oHeaders As EAGetMailObjLib.HeaderCollection Set oHeaders = oMail.Headers Dim i, nCount As Integer nCount = oHeaders.Count For i = 0 To nCount - 1 Dim oHeader As EAGetMailObjLib.HeaderItem Set oHeader = oHeaders.Item(i) MsgBox oHeader.HeaderKey & ": " & oHeader.HeaderValue Next End Sub
[VBScript] Sub ParseHeaders() Dim oMail Set oMail = CreateObject("EAGetMailObj.Mail") oMail.LicenseCode = "TryIt" oMail.LoadFile "c:\test.eml", False Dim oHeaders Set oHeaders = oMail.Headers Dim i, nCount nCount = oHeaders.Count For i = 0 To nCount - 1 Dim oHeader Set oHeader = oHeaders.Item(i) MsgBox oHeader.HeaderKey & ": " & oHeader.HeaderValue Next End Sub
[Visual C++] #include "stdafx.h" #include <windows.h> #include "eagetmailobj.tlh" using namespace EAGetMailObjLib; void ParseHeader() { try { IMailPtr oMail = NULL; oMail.CreateInstance(__uuidof(EAGetMailObjLib::Mail)); oMail->LicenseCode = _T("TryIt"); oMail->LoadFile(_T("c:\\test.eml"), VARIANT_FALSE); IHeaderCollectionPtr oHeaders; oHeaders = oMail->Headers; int count = oHeaders->Count; for(int i = 0; i < count; i++) { IHeaderItemPtr oHeader; oHeader = oHeaders->Item(i); ::_tprintf(_T("%s: %s\r\n"), (TCHAR*)oHeader->HeaderKey, (TCHAR*)oHeader->HeaderValue); } } catch(_com_error &ep) { ::_tprintf( _T("%s\r\n"), (TCHAR*)ep.Description()); } }
[Delphi] procedure ParseHeaders(); Var oMail: TMail; i: Integer; oHeaders: IHeaderCollection; oHeader: IHeaderItem; begin oMail := TMail.Create(Application); oMail.LicenseCode := 'TryIt'; oMail.LoadFile('c:\test.eml', false); oHeaders := oMail.Headers; for i := 0 To oHeaders.Count - 1 do begin oHeader := oHeaders.Item(i); ShowMessage(oHeader.HeaderKey + ':' + oHeader.HeaderValue); end; end;
See Also
Online Tutorials
Parse Email in VB6
Parse Email in Delphi
Parse Email in VC++