MailAdress Object


Provides properties and methods for presenting an e-mail address including display name, e-mail address.

IDispatch
    IMailAddress

[Visual Basic 6.0]
Public Class MailAddress
[Visual C++]
public: interface IMailAddress

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

Address Gets the e-mail address.
Name Gets the display name.

Example

[Visual Basic 6.0, VBScript, Visual C++, Delphi] The following example demonstrates how to parse from, to, cc. To get the full samples of EAGetMail, please refer to Samples section.

[Visual Basic 6.0]
Private Sub ParseMailAddress()
    Dim oMail As New EAGetMailObjLib.Mail
    oMail.LicenseCode = "TryIt"
    oMail.LoadFile "c:\test.eml", True
    
    Dim oAddr As EAGetMailObjLib.MailAddress
    Set oAddr = oMail.ReplyTo
    MsgBox "Reply-To: " & oAddr.Name & "<" & oAddr.Address & ">"
    Set oAddr = oMail.From
    MsgBox "Reply-To: " & oAddr.Name & "<" & oAddr.Address & ">"
    
    Dim i, addressList
    Set addressList = oMail.ToList
    For i = 0 To addressList.Count - 1
        Set oAddr = addressList.Item(i)
        MsgBox "To: " & oAddr.Name & "<" & oAddr.Address & ">"
    Next
    
    Set addressList = oMail.CcList
    For i = 0 To addressList.Count - 1
        Set oAddr = addressList.Item(i)
        MsgBox "Cc: " & oAddr.Name & "<" & oAddr.Address & ">"
    Next
End Sub


[VBScript] Private Sub ParseMailAddress() Dim oMail Set oMail = CreateObject("EAGetMailObj.Mail") oMail.LicenseCode = "TryIt" oMail.LoadFile "c:\test.eml", True Dim oAddr Set oAddr = oMail.ReplyTo MsgBox "Reply-To: " & oAddr.Name & "<" & oAddr.Address & ">" Set oAddr = oMail.From MsgBox "Reply-To: " & oAddr.Name & "<" & oAddr.Address & ">" Dim i, addressList Set addressList = oMail.ToList For i = 0 To addressList.Count - 1 Set oAddr = addressList.Item(i) MsgBox "To: " & oAddr.Name & "<" & oAddr.Address & ">" Next Set addressList = oMail.CcList For i = 0 To addressList.Count - 1 Set oAddr = addressList.Item(i) MsgBox "Cc: " & oAddr.Name & "<" & oAddr.Address & ">" Next End Sub
[Visual C++] #include "stdafx.h" #include <windows.h> #include "eagetmailobj.tlh" using namespace EAGetMailObjLib; void ParseMailAddress() { ::CoInitialize(NULL); try { IMailPtr oMail; oMail.CreateInstance(__uuidof(EAGetMailObjLib::Mail)); oMail->LicenseCode = _T("TryIt"); oMail->LoadFile(_T("d:\\test.eml"), VARIANT_TRUE); IMailAddressPtr oAddr; oAddr = oMail->ReplyTo; _tprintf(_T("Reply-To: %s<%s>\r\n"), (TCHAR*)oAddr->Name, (TCHAR*)oAddr->Address); oAddr = oMail->From; _tprintf(_T("From: %s<%s>\r\n"), (TCHAR*)oAddr->Name, (TCHAR*)oAddr->Address); IAddressCollectionPtr addressList = oMail->ToList; for(LONG i = 0; i < addressList->Count; i++) { oAddr = addressList->GetItem(i); _tprintf(_T("To: %s<%s>\r\n"), (TCHAR*)oAddr->Name, (TCHAR*)oAddr->Address); } addressList = oMail->CcList; for(LONG i = 0; i < addressList->Count; i++) { oAddr = addressList->GetItem(i); _tprintf(_T("Cc: %s<%s>\r\n"), (TCHAR*)oAddr->Name, (TCHAR*)oAddr->Address); } } catch(_com_error &ep ) { _tprintf(_T("%s\r\n"), (TCHAR*)ep.Description()); } ::CoUninitialize(); }
[Delphi] procedure ParseMailAddress(); Var oMail: TMail; i: Integer; addrs: IAddressCollection; addr: IMailAddress; begin oMail := TMail.Create(Application); oMail.LicenseCode := 'TryIt'; oMail.LoadFile('d:\test.eml', false); // Parse reply-to ShowMessage('Reply-To: ' + oMail.ReplyTo.Address); // Parse email sender ShowMessage('From: ' + oMail.From.Address); // Parse email to recipients addrs := oMail.ToList; for i := 0 To addrs.Count - 1 do begin addr := addrs.Item[i]; ShowMessage('To: ' + addr.Address); End; // Parse email cc recipients addrs := oMail.CcList; for i := 0 To addrs.Count - 1 do begin addr := addrs.Item[i]; ShowMessage('Cc: ' + addr.Address); end; end;

See Also

Mail.From Property
Mail.CcList Property
Mail.ToList Property

Online Tutorials

Parse Email in VB6 - Tutorial
Parse Email in Delphi - Tutorial
Parse Email in VC++- Tutorial