Link to home
Start Free TrialLog in
Avatar of ken yup
ken yup

asked on

how do i resovle this problem in a dll?

hello sir
im unfarmilar with c++ & have written such following code,i just trying to make a dll & i have a problem ,i have google for this,however the google said it sounds like i have removed the #define variable problem,is it true?it's a #define in dll,#define as well known that meaning of unchangable variable,how do i change the value in #define, for example,i tried to make a #define as a ordinary variable,but the programe occur error,show the codes,did i missing something?

#include "quickmail.h"
#include <stdio.h>
#include "mymail3.h"


#pragma comment(lib, "libquickmail.a")

int   __stdcall sendmyemail(const char* emailservername,const char* senduser ,const char *thepass,const char* myemailaddr,const char* toname,const char* emailsendaddr,const char* thetitle,const  char* thebody,const char* attachaddr )
{

unsigned int SMTPPORT=25;

int returncode;
returncode=0;

quickmail_initialize();
quickmail mailobj = quickmail_create(myemailaddr, thetitle);

quickmail_add_to(mailobj, emailsendaddr);


quickmail_add_header(mailobj, "Importance: Low");
quickmail_add_header(mailobj, "X-Priority: 5");
quickmail_add_header(mailobj, "X-MSMail-Priority: Low");
quickmail_set_body(mailobj, thebody);

quickmail_add_body_memory(mailobj, "text/html", "This is a <b>test</b> e-mail.<br/>\nThis mail was sent using <u>libquickmail</u>.", 80, 0);

quickmail_add_attachment_file(mailobj, attachaddr, NULL);

quickmail_add_attachment_memory(mailobj, "test.log", NULL, "Test\n123", 8, 0);

const char* errmsg;
quickmail_set_debug_log(mailobj, stderr);
if ((errmsg = quickmail_send(mailobj, emailservername, SMTPPORT, senduser, thepass)) != NULL)
returncode=-1;
quickmail_destroy(mailobj);
if (returncode==0)
return 0;
else
return -1;
}


1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_destroy,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_send,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_set_debug_log,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_attachment_memory,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_attachment_file,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_body_memory,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_set_body,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_header,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_add_to,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_create,referenced in function _sendmyemail@36
1>mymail3.obj : error LNK2019:  unresolved external symbol __imp__quickmail_initialize,referenced in function _sendmyemail@36

please take a look at the original sample

http://sourceforge.net/p/libquickmail/code/HEAD/tree/test_quickmail.c#l27

#include "quickmail.h"
#include <stdio.h>
#define FROM "my@domain.com"
#define TO "someuser@domain.com"
//#define CC "otheruser@domain.com"
//#define BCC "otheruser@domain.com"
#define SMTPSERVER "smtp.mydomain.com"
#define SMTPPORT 25
#define SMTPUSER NULL
#define SMTPPASS NULL
void list_attachment_callback (quickmail mailobj, const char* filename, quickmail_attachment_open_fn email_info_attachment_open, quickmail_attachment_read_fn email_info_attachment_read, quickmail_attachment_close_fn email_info_attachment_close, void* callbackdata)
{
printf("[%i]: %s\n", ++*(int*)callbackdata, filename);
}
int main ()
{
printf("libquickmail %s\n", quickmail_get_version());
quickmail_initialize();
quickmail mailobj = quickmail_create(FROM, "libquickmail test e-mail");
#ifdef TO
quickmail_add_to(mailobj, TO);
#endif
#ifdef CC
quickmail_add_cc(mailobj, CC);
#endif
#ifdef BCC
quickmail_add_bcc(mailobj, BCC);
#endif
quickmail_add_header(mailobj, "Importance: Low");
quickmail_add_header(mailobj, "X-Priority: 5");
quickmail_add_header(mailobj, "X-MSMail-Priority: Low");
quickmail_set_body(mailobj, "This is a test e-mail.\nThis mail was sent using libquickmail.");
//quickmail_add_body_memory(mailobj, NULL, "This is a test e-mail.\nThis mail was sent using libquickmail.", 64, 0);
quickmail_add_body_memory(mailobj, "text/html", "This is a <b>test</b> e-mail.<br/>\nThis mail was sent using <u>libquickmail</u>.", 80, 0);
/**/
quickmail_add_attachment_file(mailobj, "test_quickmail.c", NULL);
quickmail_add_attachment_file(mailobj, "test_quickmail.cbp", NULL);
quickmail_add_attachment_memory(mailobj, "test.log", NULL, "Test\n123", 8, 0);
/**/
/*/
quickmail_fsave(mailobj, stdout);
int i;
i = 0;
quickmail_list_attachments(mailobj, list_attachment_callback, &i);
quickmail_remove_attachment(mailobj, "test_quickmail.cbp");
i = 0;
quickmail_list_attachments(mailobj, list_attachment_callback, &i);
quickmail_destroy(mailobj);
return 0;
/**/
const char* errmsg;
quickmail_set_debug_log(mailobj, stderr);
if ((errmsg = quickmail_send(mailobj, SMTPSERVER, SMTPPORT, SMTPUSER, SMTPPASS)) != NULL)
fprintf(stderr, "Error sending e-mail: %s\n", errmsg);
quickmail_destroy(mailobj);
return 0;
}
ASKER CERTIFIED SOLUTION
Avatar of sarabande
sarabande
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial