-4
#include <CkMailMan.h>
#include <CkEmail.h>
#include <stdio>
void ChilkatSample(void)
    {
//  The mailman object is used for sending and receiving email.
CkMailMan mailman;

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    printf("%s\n",mailman.lastErrorText());
    return;
}

//  Set the SMTP server.
mailman.put_SmtpHost("smtp.chilkatsoft.com");

//  Set the SMTP login/password (if required)
mailman.put_SmtpUsername("myUsername");
mailman.put_SmtpPassword("myPassword");

//  Create a new email object
CkEmail email;

email.put_Subject("This is a test");
email.put_Body("This is a test");
email.put_From("Chilkat Support <support@chilkatsoft.com>");
email.AddTo("Chilkat Admin","admin@chilkatsoft.com");
//  To add more recipients, call AddTo, AddCC, or AddBcc once per recipient.

//  Call SendEmail to connect to the SMTP server and send.
//  The connection (i.e. session) to the SMTP server remains
//  open so that subsequent SendEmail calls may use the
//  same connection.
success = mailman.SendEmail(email);
if (success != true) {
    printf("%s\n",mailman.lastErrorText());
    return;
}

//  Some SMTP servers do not actually send the email until
//  the connection is closed.  In these cases, it is necessary to
//  call CloseSmtpConnection for the mail to be  sent.
//  Most SMTP servers send the email immediately, and it is
//  not required to close the connection.  We'll close it here
//  for the example:
success = mailman.CloseSmtpConnection();
if (success != true) {
    printf("Connection to SMTP server not closed cleanly.\n");
}

printf("Mail Sent!\n");
}

I trying to send a STMP mail using Chilkat library. I am receiving an error: "Unresolved external '_main' referenced from C0X32.OBJ."

GibboK
  • 71,848
  • 143
  • 435
  • 658
user3764279
  • 1
  • 1
  • 4

2 Answers2

4

You need a main() function, that's the C entry point for (hosted) implementations.

It may be as simple as adding:

int main (void) {
    ChilkatSample();
    return 0;
}

to your code, or it may be a whole lot more complex.

But the bottom line is that your implementation startup code (in C0X32.OBJ) is trying to find main so it can start running your program proper.


In addition, if you're after the stdio header, you should be using:

#include <stdio.h>

rather than leaving off the extension as you currently have.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
1

You are missing the program entry point i.e. int main()

Add the main function as below

int  main ( int arc, char **argv ) 
{
    ChilkatSample();
    return 0;
}

Now, your code should look like below and should be able to compile

#include <CkMailMan.h>
#include <CkEmail.h>
#include <stdio>
void ChilkatSample(void)
    {
//  The mailman object is used for sending and receiving email.
CkMailMan mailman;

//  Any string argument automatically begins the 30-day trial.
bool success;
success = mailman.UnlockComponent("30-day trial");
if (success != true) {
    printf("%s\n",mailman.lastErrorText());
    return;
}

//  Set the SMTP server.
mailman.put_SmtpHost("smtp.chilkatsoft.com");

//  Set the SMTP login/password (if required)
mailman.put_SmtpUsername("myUsername");
mailman.put_SmtpPassword("myPassword");

//  Create a new email object
CkEmail email;

email.put_Subject("This is a test");
email.put_Body("This is a test");
email.put_From("Chilkat Support <support@chilkatsoft.com>");
email.AddTo("Chilkat Admin","admin@chilkatsoft.com");
//  To add more recipients, call AddTo, AddCC, or AddBcc once per recipient.

//  Call SendEmail to connect to the SMTP server and send.
//  The connection (i.e. session) to the SMTP server remains
//  open so that subsequent SendEmail calls may use the
//  same connection.
success = mailman.SendEmail(email);
if (success != true) {
    printf("%s\n",mailman.lastErrorText());
    return;
}

//  Some SMTP servers do not actually send the email until
//  the connection is closed.  In these cases, it is necessary to
//  call CloseSmtpConnection for the mail to be  sent.
//  Most SMTP servers send the email immediately, and it is
//  not required to close the connection.  We'll close it here
//  for the example:
success = mailman.CloseSmtpConnection();
if (success != true) {
    printf("Connection to SMTP server not closed cleanly.\n");
}

printf("Mail Sent!\n");
}

int  main ( int arc, char **argv ) 
{
    ChilkatSample();
    return 0;
}
Ankit Patel
  • 1,191
  • 1
  • 9
  • 9