|
|
Hello,
I got this code from msdn. when iam trying to send an email using the local path iam getting an error. can you find the bug? Thanks in advance
#include <edk.h>
/*HRESULT SetMessageProp ( LPMAPISESSION m_pSession,
LPMESSAGE lpMessage);*/
HRESULT ShowForm ( LPMAPISESSION m_pSession,HWND m_hWnd)
{
enum {SUBJECT, CLASS, BODY, MSG_DEL, MSG_PROPS };
LPATTACH pAtt = NULL;
ULONG ulAttNum;
HRESULT hRes = S_OK;
enum {MSG_CLASS, MSG_STATUS, MSG_FLAGS, MSG_ACCESS };
LPSPropValue pProps = NULL;
LPMAPIFOLDER lpFolder = NULL;
LPMESSAGE pMsg = NULL;
LPMAPIFORMMGR pFormMgr = NULL;
LPMAPIFORMINFO pFormInfo = NULL;
LPPERSISTMESSAGE pPersistMessage = NULL;
ULONG ulMessageToken = 0L,
cValues = 0L;
LPSPropValue pPropsMsg = NULL;
LPMDB lpStore = NULL;
ULONG FAR * lpulMessageToken = NULL;
// Message properties tag array
SizedSPropTagArray ( 4, sptMsgProps ) = { 4,
PR_MESSAGE_CLASS,
PR_MSG_STATUS,
PR_MESSAGE_FLAGS,
PR_ACCESS };
CHAR szFolder[MAX_PATH + 1] = {0};
if (FAILED(hRes = HrOpenExchangePrivateStore(m_pSession,&lpStore)))
{
MessageBox(NULL,"Message Store Not Opened",NULL,MB_OK);
goto Quit;
}
strcpy(szFolder, "Top of Information Store\\Outbox");
hRes = HrMAPIOpenFolderEx (lpStore,'\\',szFolder,&lpFolder);
if (FAILED(hRes))
{
MessageBox(NULL,"Outbox Could Not Be Opened",NULL,MB_OK);
goto Quit;
}
hRes = lpFolder -> CreateMessage ( NULL, MAPI_DEFERRED_ERRORS, &pMsg );
SPropValue lpPropValueArray2[MSG_PROPS];
lpPropValueArray2[SUBJECT].ulPropTag = PR_SUBJECT;
lpPropValueArray2[SUBJECT].Value.lpszA = "Testing IPM With Attachments";
// TO DO:Change this to your custom form class
lpPropValueArray2[CLASS].ulPropTag = PR_MESSAGE_CLASS;
lpPropValueArray2[CLASS].Value.lpszA = "IPM.Note";
lpPropValueArray2[BODY].ulPropTag = PR_BODY;
lpPropValueArray2[BODY].Value.lpszA = "Custom Text For Message";
lpPropValueArray2[MSG_DEL].ulPropTag = PR_DELETE_AFTER_SUBMIT;
lpPropValueArray2[MSG_DEL].Value.b = TRUE;
if (FAILED(hRes = pMsg->CreateAttach( NULL, (ULONG)0, &ulAttNum, &pAtt)))
goto Quit;
{
enum {METHOD,RENDERING,PATH, FILENAME, DISPLAYNAME, NUM_ATT_PROPS};
SPropValue spvAttach[NUM_ATT_PROPS];
spvAttach[METHOD].ulPropTag = PR_ATTACH_METHOD;
spvAttach[METHOD].Value.l = ATTACH_BY_REFERENCE;
spvAttach[RENDERING].ulPropTag = PR_RENDERING_POSITION;
spvAttach[RENDERING].Value.l = -1;
spvAttach[PATH].ulPropTag = PR_ATTACH_PATHNAME;
spvAttach[PATH].Value.lpszA ="c:\\winzip.log";
CHAR sztemp[256];
ScUNCFromLocalPath(spvAttach[PATH].Value.lpszA,sztemp,256);
spvAttach[PATH].Value.lpszA = sztemp;
spvAttach[FILENAME].ulPropTag = PR_ATTACH_FILENAME;
spvAttach[FILENAME].Value.lpszA = "winzip.log";
spvAttach[DISPLAYNAME].ulPropTag = PR_DISPLAY_NAME;
spvAttach[DISPLAYNAME].Value.lpszA = "winzip.log";
// Save the properties we have set on the attachment
if (FAILED(hRes = pAtt ->SetProps(
NUM_ATT_PROPS,
(LPSPropValue)&spvAttach,
NULL)))
goto Quit;
if (FAILED(hRes = pAtt->SaveChanges(0)))
goto Quit;
}
// if (FAILED(hRes = lpMessage->SetProps(MSG_PROPS,lpPropValueArray2,NULL)))
// goto Quit;
// hRes = pFolder -> CreateMessage ( NULL, 0L, &pMsg );
if (FAILED(hRes = pMsg->SetProps(MSG_PROPS,lpPropValueArray2,NULL)))
goto Quit;
if ( SUCCEEDED ( hRes ) )
hRes = pMsg -> SaveChanges ( KEEP_OPEN_READWRITE );
// Need to know certain properties of message for ShowForm.
hRes = pMsg -> GetProps ( (LPSPropTagArray)&sptMsgProps,
0L,
&cValues,
&pPropsMsg );
// Get an IFormManager interface pointer
if ( FAILED ( hRes = MAPIOpenFormMgr ( m_pSession, &pFormMgr ) ) )
goto Quit;
// Use the message class of the message to resolve to the correct
// message class.
if ( FAILED ( hRes = pFormMgr->ResolveMessageClass (
pPropsMsg[0].Value.lpszA,
MAPIFORM_EXACTMATCH,
NULL,
&pFormInfo ) ) )
goto Quit;
// Create an instance of the form and store is in an
// IPersistMessage interface pointer.
if ( FAILED ( hRes = pFormMgr -> CreateForm ( (unsigned long)m_hWnd,
0L,
pFormInfo,
IID_IPersistMessage,
(LPVOID*) &pPersistMessage ) ) )
goto Quit;
// Prepare the form to be loaded by getting its token.
if ( FAILED ( hRes = m_pSession -> PrepareForm ( NULL,
pMsg,
&ulMessageToken ) ) )
goto Quit;
// Call the session object's ShowForm method. Each of the
// properties we retreived above will be used in each of the
// corresponding parameters in this call.
if ( FAILED ( m_pSession -> ShowForm (
(unsigned long)NULL,
lpStore,
lpFolder,
NULL,
ulMessageToken,
0L,
MAPI_POST_MESSAGE ,
pPropsMsg[MSG_STATUS].Value.l,
pPropsMsg[MSG_FLAGS].Value.l,
MAPI_ACCESS_MODIFY,
"IPM.Note" )))
goto Quit;
// Clean up and release all objects no longer needed in this
// method. Be sure to return the value of hRes to the caller.
Quit:
if ( NULL != pMsg )
{
pMsg -> Release ( );
pMsg = NULL;
}
if ( NULL != pFormMgr )
{
pFormMgr -> Release ( );
pFormMgr = NULL;
}
if ( NULL != pFormInfo )
{
pFormInfo -> Release ( );
pFormInfo = NULL;
}
if ( NULL != pPersistMessage )
{
pPersistMessage -> Release ( );
pPersistMessage = NULL;
}
if ( NULL != pAtt )
{
pAtt ->Release ( );
pAtt = NULL;
}
return hRes;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR pszCmd,
int nCmdShow)
{
// Load strings, and register window classes.
LPMDB lpStore = NULL;
LPMAPISESSION lpSession = NULL;
LPMESSAGE lpMessage = NULL;
HRESULT hr = NULL;
ULONG cbEntryID = 0;
LPENTRYID lpEntryID = NULL;
LPCIID lpInterface = NULL;
ULONG ulFlags = MAPI_BEST_ACCESS;
ULONG ulObjType = 0;
LPMAPIFOLDER lpFolder = NULL;
ULONG cbEIDFolder = 0;
LPENTRYID lpEIDFolder = NULL;
CHAR szFolder[MAX_PATH + 1] = {0};
LPMAPIFOLDER lpFolder2 = NULL;
hr = MAPIInitialize(NULL);
if (FAILED(hr))
{
return 1;
}
hr = MAPILogonEx(0,"", NULL,
MAPI_LOGON_UI | MAPI_NEW_SESSION | MAPI_EXPLICIT_PROFILE,
&lpSession);
if (FAILED(hr))
{
MessageBox(NULL,"MAPI Logon failed",NULL,MB_OK);
goto cleanup;
}
ShowForm(lpSession , ::GetDesktopWindow());
cleanup:
if ( NULL != lpMessage )
{
lpMessage ->Release ( );
lpMessage = NULL;
}
if (NULL != lpFolder)
{
lpFolder->Release();
lpFolder = NULL;
}
if (lpSession)
{
lpSession->Logoff(0, 0, 0);
ULRELEASE(lpSession);
}
MAPIUninitialize();
return 0;
}
|
|
|
|
|
Hy I have developped an ActiveX that sends some messages. I still have one more problem: on the computers that have Microsoft Outlook 2000 and have alternative .pst file stores the method mapi.OpenOutbox() fails. How may I select a specific store since I have no control on the naming methods that clients use for their personal folders? One ideea would be to find what outlook version is in use on the client, count the MessageStores and select .....
Any ideea?
|
|
|
|
|
Hello all
This works fine, BUT it does NOt save the message into my sent-items folder, and I would like it to...
Any idea how can I go about it?
Cheers
Alex
|
|
|
|
|
I know your question is sixteen months old, and you've either found the answer, or given up. But for others who may be asking that question, I modified the relevant section in CreateMessage as shown below. The important part is setting the PR_SENTMAIL_ENTRYID to the box ID of the Sent Mail folder:
SizedSPropTagArray( 2, Boxes ) = {2,{PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID}} ;
DWORD cValues ;
LPSPropValue lpBoxProp ;
DWORD dwObjType ;
if ( SUCCEEDED( hr = m_pMessageStore->GetProps( (LPSPropTagArray)&Boxes, 0, &cValues, &lpBoxProp ) )
&& SUCCEEDED( hr = m_pMessageStore->OpenEntry( lpBoxProp[0].Value.bin.cb, (ENTRYID *)lpBoxProp[0].Value.bin.lpb,
NULL, MAPI_BEST_ACCESS, &dwObjType, (LPUNKNOWN *)&m_pOutBoxFolder ) )
&& SUCCEEDED( hr = m_pOutBoxFolder->CreateMessage( NULL, 0, &m_pMessage ) )
&& SUCCEEDED( hr = m_pSession->OpenAddressBook( 0, NULL, AB_NO_DIALOG, &m_pAddressBook ) )
)
{
LPADRLIST pal = NULL ;
LPSPropValue rgAdrProps = NULL ;
INT nBufSize = CbNewADRLIST( dwRecipientCount ) ;
if ( SUCCEEDED( hr = MAPIAllocateBuffer( nBufSize, (LPVOID *)&pal ) ) )
{
ZeroMemory( pal, nBufSize ) ;
pal->cEntries = dwRecipientCount ;
for ( DWORD i = 0; i < dwRecipientCount; i++ )
{
pal->aEntries[i].ulReserved1 = 0 ;
pal->aEntries[i].cValues = 2 ;
if ( SUCCEEDED( hr = MAPIAllocateBuffer( 2 * sizeof(SPropValue), (LPVOID *)&( pal->aEntries[i].rgPropVals )) ) )
{
pal->aEntries[i].rgPropVals[0].ulPropTag = PR_DISPLAY_NAME ;
pal->aEntries[i].rgPropVals[0].Value.LPSZ = const_cast<LPSTR>( ppRecipents[i] ) ;
pal->aEntries[i].rgPropVals[1].ulPropTag = PR_RECIPIENT_TYPE ;
pal->aEntries[i].rgPropVals[1].Value.l = MAPI_TO ;
}
else
break ;
}
if ( SUCCEEDED( hr = m_pAddressBook->ResolveName( 0, 0, NULL, pal ) )
&& SUCCEEDED( hr = m_pMessage->ModifyRecipients( MODRECIP_ADD, pal ) )
)
{
SPropValue props[5] = {0} ;
props[0].ulPropTag = PR_BODY ;
props[0].Value.lpszA = const_cast<LPSTR>( pMessageText ) ;
props[1].ulPropTag = PR_SUBJECT ;
props[1].Value.LPSZ = const_cast<LPSTR>( pMessageSubject ) ;
props[2].ulPropTag = PR_IMPORTANCE ;
props[2].Value.l = (bHighImportance ? IMPORTANCE_HIGH : IMPORTANCE_NORMAL) ;
props[3].ulPropTag = PR_SENTMAIL_ENTRYID ;
CopySBinary( &props[3].Value.bin, &lpBoxProp[1].Value.bin, NULL ) ;
props[4].ulPropTag = PR_MESSAGE_FLAGS ;
props[4].Value.ul = MSGFLAG_SUBMIT | MSGFLAG_READ ;
if ( SUCCEEDED( hr = m_pMessage->SetProps( 5, props, NULL ) ) )
bRetVal = true ;
}
}
}
Scot Brennecke
Software Developer
VC++ MVP
|
|
|
|
|
Hi All,
How can I get rid of this messagebox while working with outlook using external applications
I have found the apps like ClickYes PFTB and so on. I don't want to use them
Please let me know how can i do the same using my own codes
Thanks
Sudhakar
Sudhakar Chavali
|
|
|
|
|
hi !
generally according to msdn, CreateMsgService has two return favlues, S_OK and MAPI_E_NOT_FOUND. Well i used mapi to create a new imail service.I am adding the service to a new profile that i am creating.In some machines it is working perfectly.In some others however there is an error.Note that MAPI is initializing properly and the profile is getting created.However CreateMsg service ( return type hr ) is returning failure , but the failure code is NOT MAPI_E_NOT_FOUND. I have checked that the necessary entries in MAPISVC.inf file is there and the two .dll files , minet32.dll and inetab32.dll is also there.any idea why this error could have occured ?
Actually the original .inf file in that machine didn't jave the entries.So i took the .inf file of a different machine..and put it there.Does that make it a problem ?
Kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason, huh?"
|
|
|
|
|
hi ! thru : bool CreateMsgService(LPTSTR lpszService, LPTSTR lpszDisplayName)
we can create a service , but that pops up a property sheet page thru which user has to enter data to create the service.How can we fill in the information programatically ? I have seen a lot of applications automatically add services.I thought of two possible ways.One is that they might be an option using some other API or modified version of this one, or else use Inter process communication to send a WM_MINIMIZe to the property sheet page , and then using SetWindowText( ) after retrieveing the windows handle and detecting the fields.This is theoritically possible but sounds a bit clumsy isn't it ? I am sure it is possible somehow...you have any idea ?
Can you also explain to me the usage of ConfigureMsgService ? I could not find the proper docs in MSDN..
Thanks in advance
Regards
Kane
"Some guys hack just to get themselves a girlfriend.What a pathetic reason ,huh ?"
|
|
|
|
|
After mail has been successfully sent I'm getting "MSMAPI32.DLL Access Vialoation" message. This happens ONLY when running Debug version of the application. Does anyone know why this is happening and how to fix it?
Thanks in advance!
|
|
|
|
|
Hi,
I want some help/hint on how we can place an image in the header of the preview pane using Extended MAPI. This would be for Outlook and Outlook express also. We can show a thumbnail of sender in the righthand space of the preview pane header where we see sender, receiver email addresses and subject in gray background.
Thanks,
Hrishi
|
|
|
|
|
How can I add attachment to the message - I dont see any function that does that?
|
|
|
|
|
Answered myself:
In CreateMessage() add the following *before*
rangeva wrote:
if (bHighImportance)
{
prop.ulPropTag = PR_IMPORTANCE;
prop.Value.l = IMPORTANCE_HIGH;
hr = m_pMessage->SetProps(1, &prop, NULL);
if (FAILED(hr)) return false;
}
return true;
rangeva wrote:
/************ Attachment ***************************/
ULONG ulAttNum;
CComPtr<iattach> pAtt;
hr = m_pMessage->CreateAttach(
NULL, // standard interface
0, // don't defer errors
&ulAttNum, // put the index of the attachment here (probably 0?)
&pAtt); // put the attachment here.
if (FAILED(hr)) return false;
{
CComPtr<istream> strAttachment;
hr = pAtt->OpenProperty(
PR_ATTACH_DATA_BIN, // the binary data of the attachment
(LPIID)&IID_IStream, // open it as a stream
0, // no extra data for the stream
MAPI_MODIFY | MAPI_CREATE, // want to write to it, create it because it's not there yet
(LPUNKNOWN*) &strAttachment); // put it in here.
if (FAILED(hr)) return false;
const unsigned char * lpbSampleRTFBytes = (const unsigned char*)apBuffer;
ULONG cSampleRTFLength = anBufSize;
ULONG cBytesWritten;
hr = strAttachment->Write(
lpbSampleRTFBytes, // this is the data
cSampleRTFLength, // this much data
&cBytesWritten); // reuse this variable -- how much data we got back
if (FAILED(hr)) return false;
}
// Fill in the rest of the attachment data:
enum {FILENAME,METHOD,RENDERING,NUM_ATT_PROPS};
SPropValue spvAttach[NUM_ATT_PROPS];
// Some filename or other.
spvAttach[FILENAME].ulPropTag = PR_ATTACH_FILENAME;
spvAttach[FILENAME].Value.lpszA = "FileName.ext";
// How do we attach it? The `value of the' attachment is in the PR_ATTACH_DATA_BIN property.
spvAttach[METHOD].ulPropTag = PR_ATTACH_METHOD;
spvAttach[METHOD].Value.l = ATTACH_BY_VALUE;
// Don't render it as anything, just attach it.
spvAttach[RENDERING].ulPropTag = PR_RENDERING_POSITION;
spvAttach[RENDERING].Value.l = -1;
hr = pAtt->SetProps(
NUM_ATT_PROPS, // how many to set?
(LPSPropValue)&spvAttach, // what do we want to set?
NULL); // no problem array back.
if (FAILED(hr)) return false;
// And save these changes. We're done with this attachment, so don't keep it open
// for reading/writing/suchlike.
hr = pAtt->SaveChanges(0);
if (FAILED(hr)) return false;
/***************************************************/
|
|
|
|
|
I do not think your extra code compile.
What is apBuffer?
What is anBufSize?
How can I make this work with a file I have created and want to attach?
Thank you/
|
|
|
|
|
apBuffer = The attachment binary data and anBufSize is its size
|
|
|
|
|
Thank you. I can add data to my file but can you say how to copy my binary file to the attachment so that if I have a file file.bin that I must attach, I must read the data from that file and write it to the my attachment using the IStream I got when I called OpenProperty() on my attachment.
|
|
|
|
|
HI the above code is marvelous..
But it lacks one major feature...That is sending the OLE objects as attachements. Do u have any idea how to proceed in this particualr area. I know that it involves setting PR_ATTACH_METHOD as ATTACH_OLE.
But My doubt is how exactly to convert the Variant object(passed from Outlook) into a stream...
|
|
|
|
|
The easy way
Just add this code:
/*********Attachmentt*************/
LPATTACH pAtt = NULL;
ULONG ulAttNum=0;
if (FAILED(hr = m_pMessage->CreateAttach( NULL, (ULONG)0, &ulAttNum, &pAtt)))
return false;
enum {METHOD,RENDERING,PATH, FILENAME, DISPLAYNAME, NUM_ATT_PROPS};
SPropValue spvAttach[NUM_ATT_PROPS];
spvAttach[METHOD].ulPropTag = PR_ATTACH_METHOD;
spvAttach[METHOD].Value.l = ATTACH_BY_REFERENCE;
spvAttach[RENDERING].ulPropTag = PR_RENDERING_POSITION;
spvAttach[RENDERING].Value.l = -1;
spvAttach[PATH].ulPropTag = PR_ATTACH_PATHNAME;
spvAttach[PATH].Value.lpszA ="File path";
spvAttach[FILENAME].ulPropTag = PR_ATTACH_FILENAME;
spvAttach[FILENAME].Value.lpszA = "Your file.ext";
spvAttach[DISPLAYNAME].ulPropTag = PR_DISPLAY_NAME;
spvAttach[DISPLAYNAME].Value.lpszA = "Great code.txt";
// Save the properties we have set on the attachment
if (FAILED(hr = pAtt ->SetProps(
NUM_ATT_PROPS,
(LPSPropValue)&spvAttach,
NULL)))
return false;
if (FAILED(hr = pAtt->SaveChanges(0)))
return false;
Before:
if (bHighImportance)
{
prop.ulPropTag = PR_IMPORTANCE;
prop.Value.l = IMPORTANCE_HIGH;
hr = m_pMessage->SetProps(1, &prop, NULL);
if (FAILED(hr)) return false;
}
return true;
And Thanks for that great code.
www.smartplant.cl
|
|
|
|
|
but when i used it to python , the attachment is wrong !why ??
#!/usr/bin/env python
"""module to send mail with Extended MAPI using the pywin32 mapi wrappers..."""
# this was based on Jason Hattingh's C++ code at http://www.codeproject.com/internet/mapadmin.asp
# written by David Fraser <davidf at sjsoft.com> and Stephen Emslie <stephene at sjsoft.com>
# you can test this by changing the variables at the bottom and running from the command line
from win32com.mapi import mapi
from win32com.mapi import mapitags
from stat import *
import os
import pythoncom
# Pre 2.2.1 compat.
try: True, False
except NameError: True = 1==1; False = 1==0
def SendEMAPIMail(Subject="", Message="", SendTo=None, SendCC=None, SendBCC=None, MAPIProfile=None):
"""Sends an email to the recipient using the extended MAPI interface
Subject and Message are strings
Send{To,CC,BCC} are comma-separated address lists
MAPIProfile is the name of the MAPI profile"""
# initialize and log on
mapi.MAPIInitialize(None)
session = mapi.MAPILogonEx(0, MAPIProfile, None, mapi.MAPI_EXTENDED | mapi.MAPI_USE_DEFAULT)
messagestorestable = session.GetMsgStoresTable(0)
messagestorestable.SetColumns((mapitags.PR_ENTRYID, mapitags.PR_DISPLAY_NAME_A, mapitags.PR_DEFAULT_STORE),0)
while (True):
rows = messagestorestable.QueryRows(1, 0)
if len(rows) != 1:
break
row = rows[0]
propertyid, propertyvalue = row[0]
if (propertyid == mapitags.PR_DEFAULT_STORE and propertyvalue == True):
break
# unpack the row and open the message store
(eid_tag, eid), (name_tag, name), (def_store_tag, def_store) = row
msgstore = session.OpenMsgStore(0,eid,None,mapi.MDB_NO_DIALOG | mapi.MAPI_BEST_ACCESS)
# get the outbox
hr, props = msgstore.GetProps((mapitags.PR_IPM_OUTBOX_ENTRYID), 0)
(tag, eid) = props[0]
outboxfolder = msgstore.OpenEntry(eid,None,mapi.MAPI_BEST_ACCESS)
# create the message and the addrlist
message = outboxfolder.CreateMessage(None,0)
# note: you can use the resolveaddress functions for this. but you may get headaches
pal = []
def makeentry(recipient, recipienttype):
return ((mapitags.PR_RECIPIENT_TYPE, recipienttype),
(mapitags.PR_SEND_RICH_INFO, False),
(mapitags.PR_DISPLAY_TYPE, 0),
(mapitags.PR_OBJECT_TYPE, 6),
(mapitags.PR_EMAIL_ADDRESS_A, recipient),
(mapitags.PR_ADDRTYPE_A, 'SMTP'),
(mapitags.PR_DISPLAY_NAME_A, recipient))
if SendTo:
pal.extend([makeentry(recipient, mapi.MAPI_TO) for recipient in SendTo.split(",")])
if SendCC:
pal.extend([makeentry(recipient, mapi.MAPI_CC) for recipient in SendCC.split(",")])
if SendBCC:
pal.extend([makeentry(recipient, mapi.MAPI_BCC) for recipient in SendBCC.split(",")])
# add the resolved recipients to the message
message.ModifyRecipients(mapi.MODRECIP_ADD,pal)
iAttach = message.CreateAttach(None,0)
iAttach[1].SetProps([
(mapitags.PR_ATTACH_METHOD, mapi.ATTACH_BY_REFERENCE),
(mapitags.PR_RENDERING_POSITION, -1),
(mapitags.PR_ATTACH_LONG_FILENAME, 'c:\\0.pdf'),
(mapitags.PR_ATTACH_FILENAME, '0.pdf')
])
iAttach[1].SaveChanges(0)
message.SetProps([(mapitags.PR_BODY_A,Message),
(mapitags.PR_SUBJECT_A,Subject)
])
CLEAR_READ_FLAG = 4
message.SetReadFlag(CLEAR_READ_FLAG)
message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)])
# save changes and submit
outboxfolder.SaveChanges(0)
message.SubmitMessage(0)
def test():
MAPIProfile = "outlook"
SendTo = "xxx@sina.com"
SendCC = None
SendBCC = None
SendMessage = "testing one two three"
# SendSubject = "Testing Simple MAPI!!"
# SendMAPIMail(SendSubject, SendMessage, SendTo, MAPIProfile=MAPIProfile)
SendSubject = "Testing Extended MAPI!!"
print SendSubject
SendEMAPIMail(SendSubject, SendMessage, SendTo, MAPIProfile=MAPIProfile)
if __name__ == '__main__':
MAPIProfile = ""
# Change this to a valid email address to test
SendTo = "cxl2253@sina.com.cn"
SendMessage = "testing one two three"
SendSubject = "Testing Extended MAPI!!"
SendEMAPIMail(SendSubject, SendMessage, SendTo, MAPIProfile=MAPIProfile)
|
|
|
|
|
Hi All,
I am trying to get SMTP email address using MAPI functions in VB.
So far, I am not successful in getting that.
Here is what I am doing:
1. Use MAPILogon to get MAPI session handle,
2. Use BMAPIAddress to show address selection dialog box with session
handle got in step 1 above.
3. Select 3/4 addresses in that dialog box and click "To:" to copy the names
to "To:" edit control and click OK.
4. Use ResolveName to get properties of recipients selected in step 3.
5. I should have smtp email address in Address attribute of recipient.
I am getting address internal to Outlook, but not smtp(xxx@yyy.com) in step 5.
Can anyone please tell me, how I can get smtp address using above approach
if possible? If not, are there any other techniques to get SMTP address using
MAPI functions?
Thanks in advance,
Reddy
|
|
|
|
|
I'm having the same problem! I'm trying to obtain an SMTP address from the GAL using the MAPISession and MAPIMessages ActiveX controls, and I keep getting some kind of Exchange specific addresses (not SMTP).
Did you ever find a workaround for this?
Thanks!
|
|
|
|
|
I need get the EntryId from a Exchange Message in c++. I can get it in Visual Basic correctly, but in c++ I obtain a different value. Why?.
This is my code:
------------------------------------------------------------------------------
for (ULONG ulIndex = 0; ulIndex < row->cValues; ulIndex++)
{
SPropValue *lpProp = &row->lpProps[ulIndex];
if (PR_ENTRYID == lpProp->ulPropTag)
{
printf("Estoy en PR_ENTRYID");
SBinary *sTipoBin = (SBinary *)&lpProp->Value.bin;
char s[200];
sprintf(s,"longitud=%d",(int)lpProp->Value.bin.cb);
printf("",s);
char *sEntryId = new char[lpProp->Value.bin.cb*2+1];
memset (sEntryId,0, lpProp->Value.bin.cb*2+1);
for (ULONG i=0; i<lpProp->Value.bin.cb; i++)
{
sprintf (s, "i= %d, valor = %d", i, lpProp->Value.bin.lpb[i]);
sprintf(s,"%2.2X",lpProp->Value.bin.lpb[i] & 0xFF);
strcat(sEntryId,s);
}
printf("sEntryId:",sEntryId);
}
}
-----------------------------------------------------------
The real size of EntryID is 70 but with my code I get only 40 and the value is different comparing Visual Basic and C++.
Thanks in advance.
|
|
|
|
|
Hello
I have the same problem with the EntryID ....
How convert from vb Cstring EntryId to c++ EntryId ?
|
|
|
|
|
The size of EntryID in VB is different from EntryID in C++!!
in VB they use the ascii version of the EntryID, in C++ they use binary form (Like UUEncoding)
U can convert between the two using some mapi functions!
Mads "Mazzachre" Randstoft
IntraVision - Insight Business
|
|
|
|
|
When i modify the code for unicode
value.lpszA parameter doesnot contain any value.
value.lpszw also doesnt work
how to make it unicode compliant.
|
|
|
|
|
Unfortunately, I was not able to work with Exchange Server 5.5 using MAPI in UNICODE. It simply failed when I called MAPIInitialize or tried to connect to a message store (do not remember exactly). I do not know if Exchange 2000 will react the same way.
In my case I implemented a regular (not Unicode) DLL for connecting to MAPI and Exchange Server returns encoded Unicode characters in most of MAPI properties. It encodes them as in HTML: "{"
--
Best Regards,
Andrew
|
|
|
|
|