diff --git a/dlls/inetcomm/mimeole.c b/dlls/inetcomm/mimeole.c index d63da8c8993..36c3ec9720f 100644 --- a/dlls/inetcomm/mimeole.c +++ b/dlls/inetcomm/mimeole.c @@ -1706,6 +1706,8 @@ static HRESULT WINAPI MimeMessage_Load(IMimeMessage *iface, IStream *pStm) return E_FAIL; } + empty_body_list(&This->body_tree); + IStream_AddRef(pStm); This->stream = pStm; offsets.cbBoundaryStart = offsets.cbHeaderStart = 0; @@ -2544,6 +2546,8 @@ static const IMimeMessageVtbl MimeMessageVtbl = HRESULT MimeMessage_create(IUnknown *outer, void **obj) { MimeMessage *This; + MimeBody *mime_body; + body_t *root_body; TRACE("(%p, %p)\n", outer, obj); @@ -2564,6 +2568,10 @@ HRESULT MimeMessage_create(IUnknown *outer, void **obj) list_init(&This->body_tree); This->next_index = 1; + mime_body = mimebody_create(); + root_body = new_body_entry(mime_body, This->next_index++, NULL); + list_add_head(&This->body_tree, &root_body->entry); + *obj = &This->IMimeMessage_iface; return S_OK; } diff --git a/dlls/inetcomm/tests/mimeole.c b/dlls/inetcomm/tests/mimeole.c index 7e985636a7d..2b6dee202c4 100644 --- a/dlls/inetcomm/tests/mimeole.c +++ b/dlls/inetcomm/tests/mimeole.c @@ -332,6 +332,27 @@ static void test_CreateMessage(void) IStream_Release(stream); } +void test_BindToObject(void) +{ + HRESULT hr; + IMimeMessage *msg; + IMimeBody *body; + ULONG count; + + hr = MimeOleCreateMessage(NULL, &msg); + ok(hr == S_OK, "ret %08x\n", hr); + + hr = IMimeMessage_CountBodies(msg, HBODY_ROOT, TRUE, &count); + ok(hr == S_OK, "ret %08x\n", hr); + ok(count == 1, "got %d\n", count); + + hr = IMimeMessage_BindToObject(msg, HBODY_ROOT, &IID_IMimeBody, (void**)&body); + ok(hr == S_OK, "ret %08x\n", hr); + IMimeBody_Release(body); + + IMimeMessage_Release(msg); +} + START_TEST(mimeole) { OleInitialize(NULL); @@ -340,5 +361,6 @@ START_TEST(mimeole) test_CreateBody(); test_Allocator(); test_CreateMessage(); + test_BindToObject(); OleUninitialize(); }