trichview.com

trichview.support




Re: Embbeded image in html for sending mails in html format


Return to index


Author

Message

Etienne van Tonder

Posted: 10/21/2003 1:32:45


Hi Samrat,


I've just completed this task myself, as Sergey suggested you need to use

OnHTMLSaveImage where you save the image to a temp directory, here is some

example code it is in C++ but if you do a search of the newsgroup you should

be able to find a Delphi example.


void __fastcall TdatEMailSend::rvvMessageHTMLSaveImage(

      TCustomRichView *Sender, TCustomRVData *RVData, int ItemNo,

      const AnsiString Path, TColor BackgroundColor, AnsiString &Location,

      bool &DoDefault)

{

    TGraphic *gr;

    int Tag;

    TRVVAlign VAlign;

    AnsiString Name;


    gr = NULL;

    if (ItemNo < 0)

    {

        if (dynamic_cast<TRVTableCellData *>(RVData))

            gr = dynamic_cast<TRVTableCellData *>(RVData)->BackgroundImage;

        else

            gr = Sender->BackgroundBitmap;

    }

    else

    {

        if (RVData->GetItemStyle(ItemNo) == rvsPicture ||

            RVData->GetItemStyle(ItemNo) == rvsHotPicture)

            gr = dynamic_cast<TRVGraphicItemInfo

*>(RVData->GetItem(ItemNo))->Image;

        else if (RVData->GetItemStyle(ItemNo) == rvsListMarker)

            gr = dynamic_cast<TRVMarkerItemInfo *>(


RVData->GetItem(ItemNo))->GetLevelInfo(Sender->Style)->Picture->Graphic;

        else if (RVData->GetItemStyle(ItemNo) == rvsTable)

            gr = dynamic_cast<TRVTableItemInfo

*>(RVData->GetItem(ItemNo))->BackgroundImage;

    }


    if (gr != NULL)

    {

        AnsiString tDir = Tglobals::GetTempDirectory();

        Location = "cid:" +

            RVData->SavePicture(rvsfHTML, "img", tDir, Sender->imgSaveNo,

            true, BackgroundColor, gr);

        DoDefault = false;

    }

}



If you are using Indy you can do the following to include the images in the

message:


        for (int i=1; i<=rvvMessage->imgSaveNo; i++)

        {

            AnsiString ImageName = "img" + AnsiString(i) + ".jpg";

            TIdAttachment *attach =

                new TIdAttachment(indEMailSend->MessageParts, (tDir +

ImageName));

            attach->ContentType = "image/jpg";

            attach->ContentDisposition = "inline";

            attach->ExtraHeaders->Values["Content-ID"] = "<" + ImageName +

">";

        }



HTH,


Etienne.



"samratdhamale" <[email protected]> wrote in message

news:[email protected]...

>

> We want to send emails in HTML format with images embbeded within the

mail.

> Since we are developing generic email client,  we dont want to save image

> on the site.

>

> Thank you,

> Samrat.





Powered by ABC Amber Outlook Express Converter