Link to home
Start Free TrialLog in
Avatar of Moshe072898
Moshe072898

asked on

How can I send a mail modelessly?

Our program gives user a way to send a mail message. Currently we use MAPISendMail function from MAPI32.DLL.
But in that way of sending mail I get a mail message window modal for my application, so can't do anything until I close the message window.
How can I send a mail modelessly, in the way Word does it?
Avatar of thresher_shark
thresher_shark

Creating a separate thread might work.  Look into the function AfxBeginThread.
I don't think they are using the simple MAPI functions in MS Word or ther other MS office apps.

There's a MAPI (without the word simple - and rightly so) which has a COM interface.  I think Word, Excel etc. use this.
I think a simpler method could be to use socket and
use port 25.
use the SMTP protocol and send the message.

If you want to send attacments then in www.codeguru.com
you find MFC code to send attachments through sockets.

That code is real cool and it can save you a lot of work.
all the best
Avatar of Moshe072898

ASKER

Thank  you , kumarana,
But I don't think the method you suggested suits me. I'd like to have all that UI that MAPI gives. I just wanted it to work modelessly.
I'll try a suggestion of thresher_shark.
I also think that Answer2000 is right and there is a MAPI with COM interface. If someone knows where is a sample of its using, please let me know.
Docs in Platform SDK

MSDN:
Platform SDK, and DDK Documentation / Platform SDK / Database and Messaging Services / Win32 Messaging (MAPI)

It's actually "COM like" as it was devised before COM was complete, so it has a few funnies.  Samples like there.  Third party samples are thin on the ground.
BTW a good work round with simple MAPI is to create a 2nd program with just the dialog (and say command line params), then

1. Prog A writes out file to send
2. Prog A runs Prog B
3. Prog B brings up send mail dlg
4. Prog A then continues happily on
Excuse me, kumarana for rejecting your answer. See my previous comment for reasons.
Answers2000, don't you think that you last comment contains the same idea   thresher_shark proposed, but in more complicated form? I tried this (thread)  and it works good enough except  for "minimize" button that still does not work. But I suspect that there are some Microsoft implementation tricks. If someone knows how to work around this - please let me know.
I want to give points to  thresher_shark, I just don't know how to do it.
Well it's not exactly the same, because I just wanted to make clear you don't have to create a thread.

Thresher needs to look the question, then you can grade his answer to give him the pts
Well it's not exactly the same, because I just wanted to make clear you don't have to create a thread.

Thresher needs to lock the question, then you can grade his answer to give him the pts
ASKER CERTIFIED SOLUTION
Avatar of thresher_shark
thresher_shark

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
Well, Thresher, points are yours.
What about minimize button,  it's that simple like it sounds - when you press it , it does nothing.
>> points are yours
Did you forget to grade me? :-)

About the minimize button... what about the other buttons in the corner, the maximize and the close button.  Do they work?  Also, is the minimize button enabled or disabled?
Don't worry about the points - they are yours and only yours. But if I accept your answer - you won't be able to add comments.
If you have nothing to add - I accept your answer immediately.
As for the button - it is enabled, can be pressed, two others work perfectly.
Wow that is strange.  I do not know the answer.  Perhaps you could post another question in the MFC area and others who know more about MFC could help you (I am not a real expert on the subject, see profile) :-).  Good luck and thanks for the points.