Sending email via SDK

Post here any questions/suggestions you have about novaPDF SDK or novaPDF OEM.
Post Reply
HanTim
Posts: 2
Joined: Tue Jul 02, 2013 3:00 pm

Sending email via SDK

Post by HanTim »

I'm trying to setup an automated email system for pdf forms in my Delphi application. So far I have been able to configure NovaPdf 8 that it will silently make the pdf and now I'm trying to sent it via smtp. The problem is that I get a run-time message that states that I have not defined an email recipient, but as you can see from the following code example I did.

m_novaOptions.SetOptionLong(NOVAPDF_SAVE_FOLDER_TYPE, SAVEFOLDER_CUSTOM);
m_novaOptions.SetOptionLong(NOVAPDF_SAVE_LOCATION, LOCATION_TYPE_LOCAL);
m_novaOptions.SetOptionLong(NOVAPDF_SAVE_FOLDER_TYPE, SAVEFOLDER_CUSTOM);
m_novaOptions.SetOptionString(NOVAPDF_SAVE_FOLDER, 'c:\\doc');
m_novaOptions.SetOptionString2(NOVAPDF_SAVE_FILE_NAME, 'myfile.pdf');
//do not show prompt dialog
m_novaOptions.SetOptionLong(NOVAPDF_SAVE_PROMPT_TYPE, PROMPT_SAVE_NONE);
//if file exists, override
m_novaOptions.SetOptionLong(NOVAPDF_SAVE_FILEEXIST_ACTION, FILE_CONFLICT_STRATEGY_OVERWRITE);
m_novaOptions.SetOptionBool(NOVAPDF_ACTION_DEFAULT_VIEWER, 0);

m_novaOptions.SetOptionBool(NOVAPDF_EMAIL_SEND, 1);
m_novaOptions.SetOptionLong(NOVAPDF_SENDEMAIL_ACTION, 2);
m_novaOptions.SetOptionString(NOVAPDF_EMAIL_SUBJECT, 'Your PDF');
m_novaOptions.SetOptionString(NOVAPDF_EMAIL_BODY, 'Email blablablablablablabla' + CRLF + 'More blablablabla');
m_novaOptions.SetOptionBool(NOVAPDF_EMAIL_ATTACH_PDF, 1);

m_novaOptions.SetOptionString2(NOVAPDF_SMTP_SERVER, 'my.smtp.host');
m_novaOptions.SetOptionString2(NOVAPDF_SMTP_PORT, '25');
m_novaOptions.SetOptionBool(NOVAPDF_SMTP_AUTHENTICATION, 0);
m_novaOptions.SetOptionBool(NOVAPDF_SMTP_SSL, 0);

m_novaOptions.AddEmail2(sEmailId);
m_novaOptions.AddEmailRecipient2(sEmailId, sNewRecipientId, '[email protected]',
'[email protected]', '', '');

m_novaOptions.SaveProfile();

What am I doing wrong?

Gr. HanTim

Lorant (Softland)
Posts: 177
Joined: Wed Dec 16, 2009 10:48 am

Re: Sending email via SDK

Post by Lorant (Softland) »

There is one recipient that is added by default in the profile, which has empty addresses.

For the first recipient, set the addresses like this:
m_novaOptions.GetEmailRecipient2(0, sEmailId, sNewRecipientId, sFro, sTo, sCC, sBCC);
m_novaOptions.SetEmailRecipient2(sEmailId, sNewRecipientId, 'fromme@here', 'recipient@somewhere', '', '');

If you wish to add more recipients, use the AddEmailRecipient function:
m_novaOptions.AddEmailRecipient2(sEmailId, sNewRecipientId, 'fromme@here', 'recipient@somewhere', '', '');

You can also send us an email to support@novapdf if you need more details.

Post Reply