|
 |
asp_cdo thread: CreateMHTMLBody CDO
Message #1 by soup_campbell@b... on Thu, 17 Jan 2002 06:35:42
|
|
When I build a HTML document that references Images, I choose to use
CreateMHTMLBody so that the EMail has the complete document self contained
in MIME format. If for any reason the images referenced in the original
HTML are not available, It seems that the Body will not send. It is
possible to save the new body to a stream, and later send that saved page
as an attachment, where the images appear as "blank boxes". I have used
the error checking suggested in Microsoft's Q286037
Questions:
1) How do I detect that the "building" mime body had a problem?
2) Am I using this incorrectly?
3) Is my only solution to modify the original HTML to include alt= in my
img src statements?
.
if(!CHECKHRES(hr)) goto Cleanup;
pMsg->put_From(_bstr_t(m_From));
if(!CHECKHRES(hr)) goto Cleanup;
pMsg->put_Sender(_bstr_t(m_From));
if(!CHECKHRES(hr)) goto Cleanup;
pMsg->put_Subject(_bstr_t(m_Subject));
if(!CHECKHRES(hr)) goto Cleanup;
hr=pMsg->CreateMHTMLBody(FILEBODY,cdoSuppressNone,_bstr_t(""),_bstr_t(""));
if(!CHECKHRES(hr)) goto Cleanup;
// if we cannot contact one of the servers the email would not be sent at
all
// so the solution is to save the MHTML to a file, and then send the file
pMsg->GetStream(&pStm);
if(!CHECKHRES(hr)) goto Cleanup;
pStm->SaveToFile(L"C:\\savemymessage.eml",adSaveCreateOverWrite);
if(!CHECKHRES(hr)) goto Cleanup;
pMsg->Send();
if(!CHECKHRES(hr)) goto Cleanup;
printf("Finnished with no errors\n");
getch();
Message #2 by "Siegfried Weber" <sweber@c...> on Mon, 21 Jan 2002 08:04:50 +0100
|
|
They way I do this (with VB or VBScript/JScript) is to pull the Webpage
using the XMLHTTP object that comes with MSXML (and I still use MSXML
3.0 SP2 because of known issues with v4).
That way I can retrieve the whole HTML source and parse it to check if
it was successful etc.
HTH
<Siegfried />
> -----Original Message-----
> From: soup_campbell@b... [mailto:soup_campbell@b...]
> Sent: Thursday, January 17, 2002 7:36 AM
> To: ASP CDO
> Subject: [asp_cdo] CreateMHTMLBody CDO
>
> When I build a HTML document that references Images, I choose to use
> CreateMHTMLBody so that the EMail has the complete document self
contained
> in MIME format. If for any reason the images referenced in the
original
> HTML are not available, It seems that the Body will not send. It is
> possible to save the new body to a stream, and later send that saved
page
> as an attachment, where the images appear as "blank boxes". I have
used
> the error checking suggested in Microsoft's Q286037
> Questions:
> 1) How do I detect that the "building" mime body had a problem?
> 2) Am I using this incorrectly?
> 3) Is my only solution to modify the original HTML to include alt=3D
in
my
> img src statements?
> .
> if(!CHECKHRES(hr)) goto Cleanup;
> pMsg->put_From(_bstr_t(m_From));
> if(!CHECKHRES(hr)) goto Cleanup;
> pMsg->put_Sender(_bstr_t(m_From));
> if(!CHECKHRES(hr)) goto Cleanup;
> pMsg->put_Subject(_bstr_t(m_Subject));
> if(!CHECKHRES(hr)) goto Cleanup;
> hr=3DpMsg-
> >CreateMHTMLBody(FILEBODY,cdoSuppressNone,_bstr_t(""),_bstr_t(""));
> if(!CHECKHRES(hr)) goto Cleanup;
> // if we cannot contact one of the servers the email would not be sent
at
> all
> // so the solution is to save the MHTML to a file, and then send the
file
> pMsg->GetStream(&pStm);
> if(!CHECKHRES(hr)) goto Cleanup;
> pStm->SaveToFile(L"C:\\savemymessage.eml",adSaveCreateOverWrite);
> if(!CHECKHRES(hr)) goto Cleanup;
> pMsg->Send();
> if(!CHECKHRES(hr)) goto Cleanup;
> printf("Finnished with no errors\n");
> getch();
>
>
$subst('Email.Unsub').
|
|
 |