|
BOOL
PASCAL FAR
AcceptEx (
IN SOCKET sListenSocket,
IN SOCKET sAcceptSocket,
IN PVOID lpOutputBuffer,
IN DWORD dwReceiveDataLength,
IN DWORD dwLocalAddressLength,
IN DWORD dwRemoteAddressLength,
OUT LPDWORD lpdwBytesReceived,
IN LPOVERLAPPED lpOverlapped
);
For the 2nd parameter,
why not use IN SOCKET &sAcceptSocket instead.
|
|
|
|
|
followait wrote: For the 2nd parameter,
why not use IN SOCKET &sAcceptSocket instead.
Because if you look at what a SOCKET is, you'll see that it is just an UINT_PTR. In fact a SOCKET is just a handle to a win32 internal object. So, yjust passing this handle is enough, you don't need to pass the handle by reference.
|
|
|
|
|
because the second parameter is not a return value. In AcceptEx,You need to have accept socket opened already unlike the accept API in which the socket is returned.
from msdn,
Another key difference between the AcceptEx function and the accept function is that AcceptEx requires the caller to already have two sockets:
One that specifies the socket on which to listen.
One that specifies the socket on which to accept the connection.
The sAcceptSocket parameter must be an open socket that is neither bound nor connected.
|
|
|
|
|
Is there any MFC Ribbon message box that I can use for confirmations?
|
|
|
|
|
Using 'ribbon' and 'message box' together seems to be an oxymoron to me, given that the ribbon is a menu bar replacement and message boxes don't (in 99.999999999999% of cases) have a menu bar.
So, when you say 'Ribbon', what do you really mean - can you point at a screenshot of something that illustrates what you want?
|
|
|
|
|
I think the message box is a custom dialog box.
I saw it in MS paint in Vista. When you modify a bmp and click on exit this message box pops up. Going by its look, I thought it was a ribbon message box just like there is a ribbon status bar.
|
|
|
|
|
|
|
Hi. I want to implement xml writer function using MSXML class.I can move to any particular element in the file without iterating every node. But suppose following is the xml file code.
<tr>
<td Id="A1"> Month <td>
<td Id="B1"> Net Revenue <td>
<tr>
I can only append the child of tr element and it will add it in the last, what about adding a child between A1 and B1, there is no such function to insert in between.
thanks
amit
modified on Monday, January 12, 2009 1:22 AM
|
|
|
|
|
<html>You could have checked "Ignore HTML ... " checkbox for your message.</html>
|
|
|
|
|
Thanks for that.. Meanwhile i got an article [^] by which i can accomplish my task.
Thanks
amit
|
|
|
|
|
IXMLDOMElement::insertBefore[^] should be right. You want the IXMLDOMElement interface for the <tr> element and specify the second <td> as the element in fornt of which the new element should be inserted.
|
|
|
|
|
Hi,
I am creating an application that has to send the mails automatically even in the absence of Microsoft outlook. My application is capable of sending the mails without any hitch only when outlook is running. If I close outlook and try sending the mail through my application, it will not send the mail until I run the outlook again. Is there a way to fix this problem? Is there any special API to be used?
My code snippet is as below:
HINSTANCE hlibMAPI = 0;
CString MapiDll = "MAPI32.dll";
hlibMAPI = LoadLibrary(MapiDll);
MapiRecipDesc *mapiCurrentSender;
MapiRecipDesc *lppNewRecips;
lppNewRecips->lpszAddress = "SMTP:harishkj@gmail.com";
lppNewRecips->lpszName = "Harish";
lppNewRecips->ulRecipClass = MAPI_TO;
lppNewRecips->ulEIDSize = NULL;
lppNewRecips->ulReserved = 0;
mapiCurrentSender->lpEntryID = NULL;
mapiCurrentSender->lpszAddress = "SMTP:harishkj@gmail.com";
mapiCurrentSender->lpszName = "KJ";
mapiCurrentSender->ulRecipClass = MAPI_ORIG;
mapiCurrentSender->ulEIDSize = NULL;
mapiCurrentSender->ulReserved = 0;
LPMAPISENDMAIL lpfnMAPISendMail;
LPMAPILOGON MAPILogon;
LHANDLE session = 0;
lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress (hlibMAPI, "MAPISendMail");
MAPILogon = (LPMAPILOGON) GetProcAddress (hlibMAPI, "MAPILogon");
MAPILogon(0,0,0,MAPI_NEW_SESSION,0,&session);
ULONG FAR PASCAL err = (*lpfnMAPISendMail)(session,(ULONG)AfxGetMainWnd()->m_hWnd, MAPI_LOGON_UI, 0L);
I tried with and without having a new session.
In either way it helped
Any help would be greatly appreciated.
Thanks,
KJ<pre></pre><pre></pre>
|
|
|
|
|
I've just looked at (and run) some MAPI wrapper code that I wrote several years ago. I found the following differences:
- I call
OleInitialize and MapiInitialize before opening a session - I opened my session with
MapiLogonEx , using these flags: MAPI_NO_MAIL|MAPI_EXTENDED|MAPI_USE_DEFAULT|MAPI_ALLOW_OTHERS . I don't use MAPISendMail either - I construct the message in my Exchange Server outbox and send it from there using IMessage::SubmitMessage . It works with or without Outlook running. - I added your
MAPILogon and MAPISendMail code and added message creation - that worked fine with or without Outlook running.
So, to summarise - I presume you're calling the relevant initialisation functions?
|
|
|
|
|
PS - what status code is returned from MAPILogon and MAPISendMail ? These could help diagnose your problem.
|
|
|
|
|
Hi Stuart Dootson,
Thanks for the immediate response.
I am sorry that I forgot to mention the return values.
Both "MAPILogon" and "MAPISendMail" calls returns SUCCESS_SUCCESS.
I am not getting where is the problem!
Could you please expalin in detail the code snippet which is working for you with my functions as well?
Thanks and regards,
KJ
|
|
|
|
|
Hi Stuart Dootson,
I even tried using the initialization calls you mentioned as below, but still the result is same.
LPMAPIINITIALIZE lpfnMAPIInitialize;
lpfnMAPIInitialize = (LPMAPIINITIALIZE) GetProcAddress (hlibMAPI, "MAPIInitialize");
MAPIINIT_0 mapiInitObj;
mapiInitObj.ulVersion = MAPI_INIT_VERSION;
mapiInitObj.ulFlags = MAPI_MULTITHREAD_NOTIFICATIONS;
if(OleInitialize(NULL) == S_OK)
MessageBox("SUCCESS", "OleInitialize");
if(lpfnMAPIInitialize(&mapiInitObj) == S_OK );
MessageBox("SUCCESS", "MAPIInitialize");
All the function returns success but the mail is not getting sent.
Please help me.
Thanks,
KJ
|
|
|
|
|
Here's the code I've used (note - I've #include d mapi.h before this) - obviously, my e-mail address isn't "my e-mail address". This works whether Outlook is running or not. If Outlook isn't running, I get a dialog that prompts me to choose the Outlook profile to use.
This would seem to be because the MAPILogon returns MAPI_E_LOGON_FAILURE whether or not Outlook is running when MAPI_NEW_SESSION is set. This is because a) when Outlook is running, it can't create a new session, and b) when Outlook isn't running, it doesn't know what profile to open (I have no default profile). The MAPISendMail will logon, as the flags allow it to display the logon UI.
Changing the MAPILogon flag to MAPI_LOGON_UI allows the logon UI to be displayed and so we can logon if Outlook isn't running. ANd if Outlook is running, we can logon because we've said we're willing to share an existing session.
HRESULT hr;
if (SUCCEEDED(hr = OleInitialize(NULL)) && SUCCEEDED(hr = MAPIInitialize(NULL)))
{
MapiRecipDesc mapiCurrentSender;
MapiRecipDesc lppNewRecips;
lppNewRecips.lpszAddress = "SMTP:<span style="font-style: italic;">my e-mail address</span>";
lppNewRecips.lpszName = "Stu";
lppNewRecips.ulRecipClass = MAPI_TO;
lppNewRecips.ulEIDSize = NULL;
lppNewRecips.ulReserved = 0;
mapiCurrentSender.lpEntryID = NULL;
mapiCurrentSender.lpszAddress = "SMTP:<span style="font-style: italic;">my e-mail address</span>";
mapiCurrentSender.lpszName = "Stu";
mapiCurrentSender.ulRecipClass = MAPI_ORIG;
mapiCurrentSender.ulEIDSize = NULL;
mapiCurrentSender.ulReserved = 0;
MapiMessage message =
{
0,
"Hello",
"Hello",
0,
"2009/01/12 09:01",
0,
0,
&mapiCurrentSender,
1,
&lppNewRecips,
0,
0
};
HINSTANCE hlibMAPI = 0;
hlibMAPI = LoadLibrary(_T("MAPI32.dll"));
LPMAPILOGON MAPILogon;
LHANDLE session = 0;
MAPILogon = (LPMAPILOGON) GetProcAddress (hlibMAPI, "MAPILogon");
ULONG errLogon = MAPILogon(0,0,0,MAPI_NEW_SESSION,0,&session);
LPMAPISENDMAIL lpfnMAPISendMail;
lpfnMAPISendMail = (LPMAPISENDMAIL) GetProcAddress (hlibMAPI, "MAPISendMail");
ULONG errSend = (*lpfnMAPISendMail)(session, 0, &message, MAPI_LOGON_UI, 0L);
}
|
|
|
|
|
Hi Stuart,
Thanks for the suggestions.
I tried using the exact way what you have done, but still the same problem occurs. After running this code, if I open my outlook, all the mails will be held in the outbox and will get sent only when I do Send/Receive in outlook window.
Could you please suggest any more ideas on this?
Can you explain how is your original code that doesn't make use of MAPISendMail function, but you are constructing the message in the Exchange Server outbox and send it from there using IMessage::SubmitMessage?
Thanks and regards,
KJ
|
|
|
|
|
The rough procedure is this:
- Open a MAPI session with
MAPILogonEx and get an IMAPISession interface pointer - Open your message store with
IMAPISession::GetMsgStoresTable and then IMAPISession::OpenMsgStore . This gets you an IMsgStore interface pointer. - Open your address book with
IMAPISession::OpenAddressBook . This gets you an IAddrBook interface pointer. - Open your outbox with
IMsgStore::OpenEntry to get an IMAPIFolder pointer on your Outbox. - Create the new message with
IMAPIFolder::CreateMessage . This returns an IMessage interface pointer. - Set the message attributes:
IMessage::ModifyRecipients to add recipients- The message body is either RTF (complex) or plain text (easy). For plain text, set the
PR_BODY_W property of the message - Set the 'Sent Items' folder for the message by setting the message's
PR_SENTMAIL_ENTRYID property - Set the message's subject by setting the
PR_SUBJECT_W property - Set the message type by setting the
PR_MESSAGE_CLASS_W to the correct string (I used "IPM.Note ")
- Send the message with
IMessage::SubmitMessage - Then release all the interface pointers correctly
I wrote wrappers around all the interface pointers to simplify these operations as much as possible - it's still pretty involved, though...
|
|
|
|
|
Hi Stuart Dootson,
I am really new to MAPI functions. I am trying to use the interface functions you suggested, but facing some difficulty in using them. Is it possible to put your source code here so that I can better understand how to use those functions and succeed.
Thanks and regards,
KJ
|
|
|
|
|
Can I suggest you download the Microsoft MFCMAPI[^] sample - that's got pretty much all the code that I mentioned and it's publicly available - I don't think my employers would be too happy if I were to post some of our application code
|
|
|
|
|
Hi,
I have the same issue as you, please tell me if you solve it!
I am having my app freeze when running mapi without outlook.
tkss
|
|
|
|
|
cPtr = (unsigned char *) &Float1 ;
cPtr += 3;
for (k = 0; k<=4; 4; k++)
{
*cPtr = sBuffer [BufPtr++];
cPtr--;
}
What the equivalent of pointer and address in C++ and C#. How to convert above code into C#?
Thanks
|
|
|
|
|
Hi,
pointers are available in C# although you often don't need them.
When used, you will need to turn on the "allow unsafe code" switch of the compiler,
and the "unsafe" keyword, possibly the "fixed" keyword too. I suggest you read up on those
if you can't live without pointers.
|
|
|
|