Guys I am trying To send a mail using C++ code i found from the net , when i compiled it it says

        In function `_Z13ChilkatSamplev':
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:10: undefined reference to `CkMailMan::CkMailMan()'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:14: undefined reference to `CkMailMan::UnlockComponent(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:21: undefined reference to `CkMailMan::put_SmtpHost(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:24: undefined reference to `CkMailMan::put_SmtpUsername(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:25: undefined reference to `CkMailMan::put_SmtpPassword(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:28: undefined reference to `CkEmail::CkEmail()'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:30: undefined reference to `CkEmail::put_Subject(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:31: undefined reference to `CkEmail::put_Body(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:32: undefined reference to `CkEmail::put_From(char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:33: undefined reference to `CkEmail::AddTo(char const*, char const*)'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:52: undefined reference to `CkMailMan::CloseSmtpConnection()'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:55: undefined reference to `CkEmail::~CkEmail()'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:55: undefined reference to `CkMailMan::~CkMailMan()'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:55: undefined reference to `CkEmail::~CkEmail()'
        [Linker error] C:/Users/dhayalan/Documents/mail.cpp:55: undefined reference to `CkMailMan::~CkMailMan()'
        In function `_ZN9CkMailMan9SendEmailERK7CkEmail':
        [Linker error] c:/program files/dev-cpp/mingw32/bin/../lib/gcc/mingw32/4.7.0/../../../../include/CkMailMan.h:469: undefined reference to `CkMailMan::SendEmail(CkEmail const*)'
    C:\Users\dhayalan\Documents\collect2.exe    [Error] ld returned 1 exit status

The program is :
i found this Program From http://www.example-code.com/vcpp/smtp_simpleSend.asp
And the necessary headers from http://www.chilkatsoft.com/downloads_vcpp.asp
The linker error is with in the function , as i dint call it too !
pls help and thanks in advance .

#include <CkMailMan.h>
#include <CkEmail.h>

int main(){
}

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");

   }

All your errors seem to be because the headers aren't recognized. It can't find any of the references in the headers. This problem might be better asked at the source.

On a side not here is a free imnplementation of sending email

Your errors are not due to problems with headers being recognised. If the header file was not recognised the error would be something like "cannot find header file".

These errors are linker errors. That means your code compiled fine, which means the header files were found without any problem. What cannot be found is the compiled, binary library files containnig the actual function code.

Whatever you downloaded came with two kinds of file that you need; header files, which tell the compiler about the functions (their names and what objects they accept in and what they return) and the library files that are the actual functions that do the actual work. You're not linking those library files. If you're using windows, they're probably named *.lib or *.dll. Link them. If you don't know how to link, look up how to use whatever IDE or linker you're using.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.