Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Download Full Email after Downloading Email Header C++ code to download a full email with attachments after downloading the email header. // The Chilkat Email library is also available as an ActiveX component
// or .NET class with the identical set of methods and properties.
// Fetch full email from POP3 server after fetching the header.
void EmailExample(void)
{
CkString str;
CkMailMan mailman;
// Any string passed to UnlockComponent begins the 30-day trial.
bool unlocked = mailman.UnlockComponent("30-day trial");
if (!unlocked)
{
printf("Failed to unlock component\n");
return;
}
mailman.put_MailHost("mail.chilkatsoft.com");
mailman.put_PopUsername("matt");
mailman.put_PopPassword(myPassword);
// Set the POP3 port to the standard MS Exchange Server SSL POP3 port 995
// mailman.put_MailPort(995);
// Tell the mailman to connect to POP3 using SSL
// mailman.put_PopSsl(true);
// Use GetAllHeaders to fetch each email header and the 1st N lines of
// the body from a POP3 server.
CkEmailBundle *bundle = 0;
bundle = mailman.GetAllHeaders(2); // Get 2 body lines...
if (!bundle)
{
mailman.LastErrorText(str);
printf("%s",str.getString());
return;
}
int i;
int n = bundle->get_MessageCount();
// Download the full email for the first header in the bundle:
if (n > 0)
{
CkEmail *email = bundle->GetEmail(0);
// Now get the email with full body and attachments.
CkEmail *fullEmail = mailman.GetFullEmail(email);
// Save the full email as XML.
if (fullEmail)
{
fullEmail->SaveXml("fullEmail.xml");
}
else
{
mailman.LastErrorText(str);
printf("%s",str.getString());
}
delete fullEmail;
delete email;
}
delete bundle;
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.