Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/162.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Mapi发送邮件并回复多封电子邮件 我正在用C++中的MAPI库来发送电子邮件。现在我需要我发送的电子邮件有一个回复设置为多个电子邮件,我只可以这样做一个电子邮件_C++_Mapi - Fatal编程技术网

使用Mapi发送邮件并回复多封电子邮件 我正在用C++中的MAPI库来发送电子邮件。现在我需要我发送的电子邮件有一个回复设置为多个电子邮件,我只可以这样做一个电子邮件

使用Mapi发送邮件并回复多封电子邮件 我正在用C++中的MAPI库来发送电子邮件。现在我需要我发送的电子邮件有一个回复设置为多个电子邮件,我只可以这样做一个电子邮件,c++,mapi,C++,Mapi,我一直在读,为了能够做到这一点,我需要使用对象FLATENTRYLIST()和FLATENTRY()。 我的疑问是如何在FLATENTRYLIST中存储多个FLATENTRY对象。我在C++方面的经验不是很高,所以如果有人能帮助我,我会接受的。 提前谢谢 PauloFLATENTRYLIST有中间成员,决定列表中条目的数量。 您只需要将条目存储在一个entries数组中。这是我开发的解决方案- 谢谢你的帮助 当我将EntryID复制到FlatEntry时,我将其视为复制了错误的字节数。下面是最后

我一直在读,为了能够做到这一点,我需要使用对象FLATENTRYLIST()和FLATENTRY()。 我的疑问是如何在FLATENTRYLIST中存储多个FLATENTRY对象。我在C++方面的经验不是很高,所以如果有人能帮助我,我会接受的。 提前谢谢

Paulo

FLATENTRYLIST有中间成员,决定列表中条目的数量。
您只需要将条目存储在一个entries数组中。

这是我开发的解决方案-

谢谢你的帮助

当我将EntryID复制到FlatEntry时,我将其视为复制了错误的字节数。下面是最后一段代码,它像一个符咒一样工作

boolcmapimessage::SetReplyTo(LPADRLIST lpAddrList)
{
HRESULT hRes=S_正常;
SPropValue pspvReply[1];
LPFLATENTRYLIST lpEntryList=NULL;
BOOL-bResult=false;
CString m_streplytonames;
int cb=0;
int displayNameTagID=-1;
int emailTagID=-1;
int entryIDTagID=-1;
int cbAllBytes=0;
//获取EntryID的所有字节以初始化FLATENTRYLIST
for(无符号j=0;jcEntries;j++)
{
for(无符号的i=0;iaEntries[j].cValues;i++)
{
if(lpAddrList->aEntries[j].rgPropVals[i].ulPropTag==PR\u ENTRYID)
{
entryIDTagID=i;
}
}
如果(EntryDitAgid>=0)
{
int-feBytes=CbNewFLATENTRY(lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb);
cbAllBytes+=feBytes;
cbAllBytes+=((feBytes+4&~3)-feBytes);
}   
}
//分配一个包含所有flatentries字节的新FLATENTRYLIST
cb=CbNewFLATENTRYLIST(cbAllBytes);
hRes=MAPIAllocateBuffer(cb,(LPVOID*)和lpEntryList);
如果(失败(hRes))
{
bResult=假;
去清理;
}
零内存((VOID*)lpEntryList,cb);
//将FLATENTRY的位复制到FLATENTRYLIST中。
lpEntryList->cEntries=lpAddrList->cEntries;
int countBytesAdded=0;
for(无符号j=0;jcEntries;j++)
{
for(无符号的i=0;iaEntries[j].cValues;i++)
{
if(lpAddrList->aEntries[j].rgPropVals[i].ULPROPTTAG==PR\U传输表\U显示\U名称)
{
displayNameTagID=i;
}
else if(lpAddrList->aEntries[j].rgPropVals[i].ULPROPTTAG==PR\U电子邮件地址)
{
emailTagID=i;
}
else if(lpAddrList->aEntries[j].rgPropVals[i].ulPropTag==PR\u ENTRYID)
{
entryIDTagID=i;
}
}
如果((emailTagID>=0)和(&(EntryDiagID>=0))
{
CString m_streplytoname;
CString m_streplytoemail;
m_streplytoEmail=lpAddrList->aEntries[j].rgPropVals[emailTagID].Value.lpszA;
如果(displayNameTagID>=0)
m_streplytoname=lpAddrList->aEntries[j].rgPropVals[displayNameTagID].Value.lpszA;
其他的
m_streplytoname=m_streplytoemail;
m_streplytoNames+=(CString)m_streplytoName+“;”;
//为PR_REPLY_RECIPIENT_ENTRIES属性分配新的FLATENTRY结构
LPFLATENTRY lpReplyEntry=NULL;
cb=CbNewFLATENTRY(lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb);
hRes=MAPIAllocateBuffer(cb,(LPVOID*)和lpReplyEntry);
如果(失败(hRes))
{
bResult=假;
去清理;
}
零内存((VOID*)lpReplyEntry,cb);
//将条目id的位复制到FLATENTRY结构中
CopyMemory(lpReplyEntry->abEntry,
LPADDRIST->aEntries[j].rgPropVals[entryIDTagID].Value.bin.lpb,
lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb);
lpReplyEntry->cb=lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb;
int-missingBytes=0;
int feBytes=CbFLATENTRY(lpReplyEntry);
missingBytes=((feBytes+4&~3)-feBytes);
//将每个FLATENTRY复制到先前添加的字节旁边的abEntries
CopyMemory(lpEntryList->abEntries+countBytesAdded,lpReplyEntry,feBytes);
countBytesAdded+=feBytes+missingBytes;
//清除内存
if(lpReplyEntry)MAPIFreeBuffer(lpReplyEntry);
}
displayNameTagID=-1;
emailTagID=-1;
entryIDTagID=-1;
}
lpEntryList->cbEntries=countBytesAdded;
pspvReply[0]。ulPropTag=PR\u REPLY\u RECIPIENT\u条目;
//在lpb中分配内存以保存FLATENTRYLIST
hRes=MAPIAllocateBuffer(cbflattenrylist(lpEntryList),(LPVOID*)和pspvReply[0].Value.bin.lpb);
如果(失败(hRes))
{
bResult=假;
去清理;
}
//将内存复制到SPropValue中
CopyMemory(pspvReply[0].Value.bin.lpb、lpEntryList、cbflattentryList(lpEntryList));
pspvReply[0].Value.bin.cb=CbFLATENTRYLIST(lpEntryList);
//使用所有名称设置PR_REPLY_RECIPIENT_NAMES属性
SetPropertyString(PR_回复_收件人_姓名,m_streplytoNames);
//将包含带有回复地址的FLATENTRYLIST的属性设置为消息属性
hRes=Message()->SetProps(1,pspvReply,NULL);
如果(失败(hRes))
{
bResult=假;
去清理;
}
bResult=true;
清理:
if(lpEntryList)MAPIFreeBuffer(lpEntryList);
返回结果;
}

你好,Dmitry,谢谢你的回答。是的,我看过那些房子。问题是我对C++的经验不太丰富,我找不到一种方法来设置。
BOOL CMAPIMessage::SetReplyTo(LPADRLIST lpAddrList)
{
    HRESULT hRes = S_OK;
    SPropValue pspvReply[1];
    LPFLATENTRYLIST lpEntryList = NULL;
    BOOL bResult = false;
    CString m_strReplyToNames;

    int cb = 0; 
    int displayNameTagID = -1;
    int emailTagID = -1;
    int entryIDTagID = -1;
    int cbAllBytes = 0;

    //Get all the EntryID's bytes to initalize the FLATENTRYLIST
    for(unsigned j=0; j<lpAddrList->cEntries; j++)
    {
        for (unsigned i = 0; i < lpAddrList->aEntries[j].cValues; i++)
        {
            if (lpAddrList->aEntries[j].rgPropVals[i].ulPropTag == PR_ENTRYID)
            {
                entryIDTagID = i;
            }
        }

        if (entryIDTagID >= 0)
        {
            int feBytes = CbNewFLATENTRY(lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb);

            cbAllBytes += feBytes;
            cbAllBytes += ((feBytes + 4 & ~3) - feBytes);
        }   
    }

    //Allocate a new FLATENTRYLIST with all flatentries bytes
    cb = CbNewFLATENTRYLIST(cbAllBytes);
    hRes = MAPIAllocateBuffer(cb, (LPVOID *)&lpEntryList);
    if (FAILED(hRes))
    {
        bResult = false;    
        goto Cleanup;
    }

    ZeroMemory((VOID *)lpEntryList, cb);

    // Copy the bits of the FLATENTRY into the FLATENTRYLIST.
    lpEntryList->cEntries  = lpAddrList->cEntries;

    int countBytesAdded = 0;

    for(unsigned j=0; j<lpAddrList->cEntries; j++)
    {
        for (unsigned i = 0; i < lpAddrList->aEntries[j].cValues; i++)
        {
            if (lpAddrList->aEntries[j].rgPropVals[i].ulPropTag == PR_TRANSMITABLE_DISPLAY_NAME)
            {
                displayNameTagID = i;
            }
            else if (lpAddrList->aEntries[j].rgPropVals[i].ulPropTag == PR_EMAIL_ADDRESS)
            {
                emailTagID = i;
            }
            else if (lpAddrList->aEntries[j].rgPropVals[i].ulPropTag == PR_ENTRYID)
            {
                entryIDTagID = i;
            }
        }

        if ((emailTagID>=0) && (entryIDTagID>=0))
        {
            CString m_strReplyToName;
            CString m_strReplyToEmail;

            m_strReplyToEmail=lpAddrList->aEntries[j].rgPropVals[emailTagID].Value.lpszA;

            if(displayNameTagID>=0) 
                m_strReplyToName=lpAddrList->aEntries[j].rgPropVals[displayNameTagID].Value.lpszA;
            else
                m_strReplyToName = m_strReplyToEmail;

            m_strReplyToNames += (CString)m_strReplyToName + ";";

            // Allocate a new FLATENTRY structure for the PR_REPLY_RECIPIENT_ENTRIES property
            LPFLATENTRY lpReplyEntry = NULL;

            cb = CbNewFLATENTRY(lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb);
            hRes = MAPIAllocateBuffer(cb, (LPVOID *)&lpReplyEntry);
            if (FAILED(hRes))
            {
                bResult = false;    
                goto Cleanup;
            }

            ZeroMemory((VOID *)lpReplyEntry, cb);

            // Copy the bits of the entry id into the FLATENTRY structure
            CopyMemory(lpReplyEntry->abEntry, 
                lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.lpb, 
                                lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb);

            lpReplyEntry->cb = lpAddrList->aEntries[j].rgPropVals[entryIDTagID].Value.bin.cb;

            int missingBytes  = 0;
            int feBytes = CbFLATENTRY(lpReplyEntry);

            missingBytes = ((feBytes + 4 & ~3) - feBytes);

            //Copy each FLATENTRY to the abEntries, next to the previous added bytes
            CopyMemory(lpEntryList->abEntries + countBytesAdded, lpReplyEntry, feBytes);

            countBytesAdded += feBytes + missingBytes; 

            //Clean Memory
            if (lpReplyEntry) MAPIFreeBuffer(lpReplyEntry);
        }

        displayNameTagID = -1;
        emailTagID = -1;
        entryIDTagID = -1;
    }

    lpEntryList->cbEntries = countBytesAdded;

    pspvReply[0].ulPropTag = PR_REPLY_RECIPIENT_ENTRIES;

    // Allocate memory in the lpb to hold the FLATENTRYLIST
    hRes = MAPIAllocateBuffer(CbFLATENTRYLIST(lpEntryList), (LPVOID *)&pspvReply[0].Value.bin.lpb);
    if (FAILED(hRes))
    {
        bResult = false;    
        goto Cleanup;
    }

    // Copy the memory into the SPropValue
    CopyMemory(pspvReply[0].Value.bin.lpb,lpEntryList,CbFLATENTRYLIST(lpEntryList));
    pspvReply[0].Value.bin.cb = CbFLATENTRYLIST(lpEntryList);

    //Set the PR_REPLY_RECIPIENT_NAMES property with all names
    SetPropertyString(PR_REPLY_RECIPIENT_NAMES, m_strReplyToNames);

    // Set the property that contains the FLATENTRYLIST with the reply-to adresses to the message properties
    hRes = Message()->SetProps(1,pspvReply,NULL);
    if (FAILED(hRes))
    {
        bResult = false;    
        goto Cleanup;
    }

    bResult = true; 

Cleanup:
    if (lpEntryList) MAPIFreeBuffer(lpEntryList);

    return bResult;
}