Mail.To Property


Gets an array of recipient e-mail addresses.
This property is obsoleted by ToList

[Visual Basic 6.0]
Public Property Get To() As Variant
[Visual C++]
public: get_To(VARIANT* pVal);

Property Value

A MailAddress array instance of recipient e-mail addresses.

Example

[Visual Basic 6.0, VBScript, Visual C++] 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 arAddr
    arAddr = oMail.To
    Dim i
    For i = LBound(arAddr) To UBound(arAddr)
        Set oAddr = arAddr(i)
        MsgBox "To: " & oAddr.Name & "<" & oAddr.Address & ">"
    Next
    
    arAddr = oMail.Cc
    For i = LBound(arAddr) To UBound(arAddr)
        Set oAddr = arAddr(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 arAddr arAddr = oMail.To Dim i For i = LBound(arAddr) To UBound(arAddr) Set oAddr = arAddr(i) MsgBox "To: " & oAddr.Name & "<" & oAddr.Address & ">" Next arAddr = oMail.Cc For i = LBound(arAddr) To UBound(arAddr) Set oAddr = arAddr(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); _variant_t arAddr; arAddr = oMail->To; SAFEARRAY *psa = arAddr.parray; LONG LBound = 0, UBound = 0; SafeArrayGetLBound(psa, 1, &LBound); SafeArrayGetUBound(psa, 1, &UBound); for(LONG i = LBound; i <= UBound; i++) { _variant_t vt; ::SafeArrayGetElement(psa, &i, &vt); vt.pdispVal->QueryInterface(__uuidof(IMailAddress), (void**)&oAddr); _tprintf(_T("To: %s<%s>\r\n"), (TCHAR*)oAddr->Name, (TCHAR*)oAddr->Address); } arAddr = oMail->Cc; psa = arAddr.parray; SafeArrayGetLBound(psa, 1, &LBound); SafeArrayGetUBound(psa, 1, &UBound); for(LONG i = LBound; i <= UBound; i++) { _variant_t vt; ::SafeArrayGetElement(psa, &i, &vt); vt.pdispVal->QueryInterface(__uuidof(IMailAddress), (void**)&oAddr); _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(); }

See Also

Mail.ToList Property
Mail.From Property
Mail.CcList Property
Mail.TextBody Property
Mail.HtmlBody Property
Mail.Attachments Property

Online Tutorials

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