|
Hi, I'm using the following function to send an email from my VC++ 6 application:
_________________
BOOL CEasyUpdateDlg::SendMail(CHAR *lpszFrom, CHAR *lpszTo, CHAR *lpszSubject, CHAR *lpszMessage)<br />
{<br />
BOOL bSent = FALSE;<br />
HINSTANCE hMAPI = ::LoadLibrary(_T("mapi32.dll"));<br />
if(0==hMAPI) <br />
return bSent;<br />
typedef ULONG (FAR PASCAL *PFN_MAPILogon)(ULONG,LPTSTR,LPTSTR,FLAGS,ULONG,LPLHANDLE); <br />
typedef ULONG (FAR PASCAL *PFN_MAPISendMail)(LHANDLE,ULONG,lpMapiMessage,FLAGS,ULONG); <br />
typedef ULONG (FAR PASCAL *PFN_MAPILogoff)(LHANDLE,ULONG,FLAGS,ULONG); <br />
PFN_MAPILogon MAPILogon = (PFN_MAPILogon)::GetProcAddress(hMAPI,"MAPILogon");<br />
PFN_MAPISendMail MAPISendMail = (PFN_MAPISendMail)::GetProcAddress(hMAPI,"MAPISendMail"); <br />
PFN_MAPILogoff MAPILogoff = (PFN_MAPILogoff)::GetProcAddress(hMAPI,"MAPILogoff");<br />
if((0!=MAPILogon)&&(0!=MAPISendMail)&&(0!=MAPILogoff)) <br />
{ <br />
LHANDLE session = 0; <br />
VERIFY(SUCCESS_SUCCESS==MAPILogon(0,0,0,MAPI_NEW_SESSION,0,&session)); <br />
ASSERT(0!=session); <br />
MapiRecipDesc recipient; <br />
::ZeroMemory(&recipient,sizeof(recipient)); <br />
recipient.ulRecipClass = MAPI_TO; <br />
recipient.lpszName = lpszTo; <br />
MapiMessage message; <br />
::ZeroMemory(&message,sizeof(message)); <br />
message.lpszSubject = lpszSubject; <br />
message.lpszNoteText = lpszMessage; <br />
message.nRecipCount = 1; <br />
message.lpRecips = &recipient; <br />
bSent = SUCCESS_SUCCESS == MAPISendMail(session,0,&message,0,0);<br />
} <br />
::FreeLibrary(hMAPI); <br />
return bSent;<br />
<br />
}
_________________
I have found that when I try to send a mail using:
CHAR *lpszTo="whoever@whatever.com" it works great,
but if I do:
CHAR *lpszTo="person1@whatever.com; person2@whatever.com"
no emails are send.
How can I use it to send a mail to several people, not just one recipient?
Thanks so much!
F
|
|
|
|
|
You need to have one MapiRecipDesc for each address you are sending the email to. So in your SendMail function, break up the lpszTo into multiple strings, allocate a MapiRecipDesc array that can hold the required number of items, then have a loop that fills in each MapiRecipDesc in the array. Now, make message.nRecipCount have the correct number instead of 1, and make message.lpRecips point to the MapiRecipDesc array that you allocated. Don't forget to delete the MapiRecipDesc array when you're done.
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
Chris,
will this send one mail to each of the recipients, or just one mail with the three recipients in the 'to' field?
Thanks so much!
F
|
|
|
|
|
Something like this?
MapiRecipDesc *recipient=new MapiRecipDesc[2];<br />
::ZeroMemory(&recipient,sizeof(recipient)); <br />
recipient[0].ulRecipClass = MAPI_TO;<br />
recipient[0].lpszName = "thefirst@hotmail.com"; <br />
recipient[1].ulRecipClass = MAPI_TO; <br />
recipient[1].lpszName = "thesecond@hotmail.com"; <br />
MapiMessage message; <br />
::ZeroMemory(&message,sizeof(message)); <br />
message.lpszSubject = lpszSubject; <br />
message.lpszNoteText = lpszMessage; <br />
message.nRecipCount = 2; <br />
message.lpRecips = recipient; <br />
bSent = SUCCESS_SUCCESS == MAPISendMail(session,0,&message,0,0);<br />
delete recipient;
(I've simplified and instead of breaking the original lpszTo into various strings, I'm just setting the different recipients manually. When this works, I'll do the breaking thing... But this is not working!).
|
|
|
|
|
The problem here is that you aren't zeroing out the recipient array correctly. Here's the correct way to do it:
int nRecips = 2;
MapiRecipDesc *recipient=new MapiRecipDesc[nRecips];
::ZeroMemory(recipient,sizeof(*recipient) * nRecips);
This worked fine for me. One more note: Make SURE you call MAPILogoff after you are done sending the email:
MAPILogoff( session, 0, 0, 0 );
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
Working great, Chris!
How could I thank you?
This has been a massive help for me!
F
|
|
|
|
|
I need to change the color and Font of Objects of CButton and CStatic . How can i do this ?
|
|
|
|
|
Objects derived from CWnd have a SetFont method to do just this (after the HWND is valid, i.e. created).
|
|
|
|
|
Thanks for the info .
The Font can now be effortlessly changed . I was still unable to change teh Forecolor and backcolor of the Static text window .
|
|
|
|
|
Either the parent window of the static text window needs to handle the WM_CTLCOLORSTATIC message, or if you're using MFC, your static window itself should handle the reflected message.
Hint: In either case, the HBRUSH that you use to control the back colour should persist longer than the lifetime of the handler function, or it will likely have no effect.
Steve S
[This signature space available for rent]
|
|
|
|
|
Does anyone know where keyboard macro information is stored? I don't mean where are the macros stored, but where the key/macro mapping is stored. I would like to be able to quickly configure someone else's computer to have the same key combination to macro mapping mine does.
Thanks,
Lee
|
|
|
|
|
Extra->customize->keyboard (or shortcuts -- I'm translating from the german ).
Then choose the category "Macro" and there you are
~RaGE();
|
|
|
|
|
For VC6, it's under the following keys:
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Keyboard
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Keyboard\Aut
Chris Richardson
C/C++ Include Finder[^]
|
|
|
|
|
I have VC++6 ,SP3 on WinNT.
When creating a right-aligned combo-box in WinNT it looks fine.
However, in Win98 the control is not right-aligned.
Do you have any idea how to solve this problem?
|
|
|
|
|
I have an application and it must support language choice and change at runtime.
Is there someone can help me?
Sorry for my English,
Margaria Ivano
|
|
|
|
|
|
Can anyone give me a good link for building a dynamic data exchange between a Matlab.exe and a VisualC++.exe?
Is this possible and where can I find some good information?
Thanx, kind regards,
Geert
|
|
|
|
|
I have find a function on codeguru, DDBToDIB and i get a HANDLE to DIB bitmap. and now how do this :
MAAK wrote:
<code>
HBITMAP hbmp1 = NULL, hbmp2 = NULL;
BITMAP bmp1, bmp2;
..
..
GetObject(hbmp1, sizeof(BITMAP), &bmp1);
GetObject(hbmp2, sizeof(BITMAP), &bmp2);
if(bmp1.bmBitsPixel != bmp2.bmBitsPixel || bmp1.bmHeight != bmp2.bmHeight || bmp1.bmWidth != bmp2.bmWidth)
return 0;
else
{
LPBYTE data1 = (LPBYTE)bmp1.bmBits,data2 = (LPBYTE)bmp2.bmBits;
DWORD bmWidth = bmp1.bmWidth * (bmp1.bmBitsPixel / 8);
DWORD bmWidthBytes = bmWidth + (4 - bmWidth % 4) * bool(bmWidth % 4);
DWORD bytesize = bmp1.bmHeight * bmWidthBytes;
if(memcmp(data1, data2, bytesize) == 0)
return 1;
}</code>
when i have two HANDLE on DIB ?
(sorry for stupid questions but i'm beginer)
|
|
|
|
|
well...
now I do directly :
if (memcmp(m_hDIB,hDIB,m_DIBSize)==0)
AfxMessageBox("gooood");
m_hDIB is the HANDLE on DIB of the first Bitmap;
hDIB is the HANDLE on DIB of the second Bitmap;
m_DIBSize is the size of the second DIB Bitmap;
Bitmaps are same height, same width and so same numbers of pixels.
But i want to detect if pixels are differents.
memcmp always return 0 !
You know why ?
|
|
|
|
|
Sorry but I can't understand exactly what you want.
1.Does memcmp return 0 even if the bitmaps are different? If there is any difference in pixels it should return a non-zero value, doesn't it do that?
2.The handles of the bitmaps should not be passed to memcmp, what should be passed is their bytes array did you just miss-typed the message?
|
|
|
|
|
thx for your answer but i have solved the problem, it was a problem with the size of bitmap.
now it will works fine (i hope )
Thx MAAK for your help
|
|
|
|
|
You are welcome
|
|
|
|
|
Dear Sirs,
I develop a mediaplayer (mPlayer.exe), which uses the runtime argument to pass in the file name that refers to the movie to be played back in the player.
Instead of entering the file name each time when I run the mPlayer.exe, is there any way I can develop a wrapper, which will make use of the mPlayer.exe and the file name as input and generate a new mediaplayer inside which the file name had been hardcoded. Thus a stand alone executable could be run instead of a mPlayer.exe and a file name.
I tried to do like this because only the new wrapper and the excutable mediaplayer (mPlayer.exe) could be released under my current development plan.
Thanks
DJ
|
|
|
|
|
i have the SOCKET that i use to send/recv data, now i want to know the IP adres of the connected client. how can i do this?
greetz
[]D [] []D []
|
|
|
|
|
Try this:
int namelen=sizeof(sockaddr_in);
sockaddr_in name;
getpeername(sock, (sockaddr *)&name, &namelen);
char *sz=inet_ntoa(name.sin_addr);
rechi
|
|
|
|