Archived

This topic is now archived and is closed to further replies.

*sigh* i give up, plz help.., how do I send email in VC++?...,

This topic is 5664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i''ve searched in google, in msdn, in my local msdn, the forums here and i''ve almost solved my problem using MAPI(well, i think this is the api that you''ll use).., but at the end, after using the MAPISendMail(...) i got this error which i don''t have any idea to solve it, error LNK2019: unresolved external symbol _MAPISendMail@20 referenced in function _WinMain@16 anyway, what i wanna do is, a messabebox pops up, and ask the user if he wants to send this _____ and if the user clicks on yes, his default email client, ie outlook or whatever he has, will popup, and with my email address right into the To: box, i''ve encounted also about the outlook object model, something about automation stuffs, and using the winsock but i really don''t have any ideas about these, actually, am not really sure if MAPI does the job i wanted, so.., plz help! many thanks,

Share this post


Link to post
Share on other sites
I think a call to shellexecute should do the trick:

ShellExecute(your_hwnd, "open","mailto:youremail@yourprovider.com", NULL, NULL, SW_SHOWNORMAL);

its just like an HTML reference to "mailto":

<a href="mailto:youremail@yourprovider.com">email me</a>

but used inside a program.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
your error means you probably didnt link the library you are using to the project.

Use this command anywhere in the code.
#pragma comment(lib, "*.lib"
replace * with the name of the library. MAPI or whatever.

Share this post


Link to post
Share on other sites
Just tested it, and it works, here is the simple sample console code:


  
#include <windows.h>

int main()
{
ShellExecute(NULL, "open","mailto:youremail@yourprovider.com", NULL, NULL, SW_SHOWNORMAL);
return 0;
}


Note that you can also put a "visit my webpage" button using this function, just change it to:

ShellExecute(NULL, "open","http://www.yourwebsite.com", NULL, NULL, SW_SHOWNORMAL);


Share this post


Link to post
Share on other sites
kwitz: ei, the ShellExcecute is kewl, it''s nice to know about that function, anyway, i need an api that will allow me to attach automatically the file on the email(so that i don''t need to let the user do anything),

ap, actually that''s my problem, i do not know what to include! i''ve search msdn but they didn''t specfied the right .lib, they just said what header to include, so this is what i did,

#pragma comment(lib, "mapi.lib")
#pragma comment(lib, "mapi32.lib")
#pragma comment(lib, "nmapi.lib")

which still gives me the same error...,

also, is this the api to use? MAPI?

Share this post


Link to post
Share on other sites
Well you can always do it manually, which I find less anoying than learning to use MAPI
you would have to research on socket programming and the smtp protocol, maybe MIME 64 encoding too.
I have done this for sending email, but never tryed to atach files.
anyway here is rfc 821 on SMTP. its not hard at all, the hard part I think would be guessing the users SMTP server address.

Sorry, I would help you with MAPI, but I know nothing about that API.


Share this post


Link to post
Share on other sites
smtp and winsock? but winsock are just for sendind messages(not email per se)right? and smtp will it open the default email's client?

i've also encoundered Collaboration Data Objects (CDO), which gives additional functionality for MAPI, any idea about this, i've seen the example in the sdk, but everything is in VB ?

yikes!



[edited by - mickey on June 5, 2002 11:55:22 PM]

Share this post


Link to post
Share on other sites
winsock an api used to transmit packets across a network. smtp is the simple mail transfer protocal, and used by email clients to send emails. thats all you need to send emails. you dont need to activate the email client. you connect the server specified after the @ and then do as the smtp protocal says (ussually works). after that you close the connection. many isps offer a smtp server for you to cpnnect to, which will handle resnding the message, queueing and generally helps ensure better more reliable transfer. this though can be specified in the config (anyone using an email client should be able to look this information up, though i am sure you could figure it out through some function calls or reading a register key).

there is plenty of information about this on the net. do some research and expiermentation. i suggest getting a mail server for yourself to test on, instead of sending emails through the net since too many malformed (ie bad) requests could land you on a blacklist (i blocked from sending mail to that server). plus some isps will notice the increase in mail usage and think you may be sending spam, even if its to yourself.


though the ShellExecute() method posted previously is pretty much what you want.

[edited by - a person on June 9, 2002 3:59:50 AM]

Share this post


Link to post
Share on other sites
Try this

http://win32programming.tripod.com/Win32tips06.html

Then if the #pragma comment is not working then you should learn how to add libraries to your project manually.

Share this post


Link to post
Share on other sites
*wow*, thanks very very much for the link mindflayer! i''ve tried and yes, that''s what i want to happen! actually, i think it ''silently'' emails the file to the programmer, thanks!!!

a person, thanks too for those info, i''ve been reading all those stuffs but really don''t know what to use.

Share this post


Link to post
Share on other sites
a person:

you said something about, ''getting a mail server for yourself to test on'', ehm, would you plz tell me where would i start on how to do this? would i do this on a linux system or can i do it here on my WinXP? do i need some kind of softwares for these? thanks,

Share this post


Link to post
Share on other sites