To unzip a docx, change its extension from docx to zip, and use an unzip utility.
Here is a basic outline of what you need to do to add the outlook message.
1. create a OleObjectBinaryPart using its constructor
2 inject the outlook message into your OleObjectBinaryPart (it extends BinaryPart, which contains the methods you need). Injecting the outlook message in the correct format may be a challenge. See
viewtopic.php?f=6&t=72 for generic embedding info; the web may well contain something more specific to outlook. Refer also to the relevant Microsoft OLE specs.
3 add the part to the main document part, using you main document part's AddTargetPart method. it will return the rel, which you need for the next step
4. the main document part of your sample contained:
- Code: Select all
<w:p>
<w:r>
<w:object w:dxaOrig="1454" w:dyaOrig="941">
<v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f">
<v:stroke joinstyle="miter"/>
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0"/>
<v:f eqn="sum @0 1 0"/>
<v:f eqn="sum 0 0 @1"/>
<v:f eqn="prod @2 1 2"/>
<v:f eqn="prod @3 21600 pixelWidth"/>
<v:f eqn="prod @3 21600 pixelHeight"/>
<v:f eqn="sum @0 0 1"/>
<v:f eqn="prod @6 1 2"/>
<v:f eqn="prod @7 21600 pixelWidth"/>
<v:f eqn="sum @8 21600 0"/>
<v:f eqn="prod @7 21600 pixelHeight"/>
<v:f eqn="sum @10 21600 0"/>
</v:formulas>
<v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"/>
<o:lock v:ext="edit" aspectratio="t"/>
</v:shapetype>
<v:shape id="_x0000_i1025" type="#_x0000_t75" style="width:73.2pt;height:46.8pt" o:ole="">
<v:imagedata r:id="rId4" o:title=""/>
</v:shape>
<o:OLEObject Type="Embed" ProgID="Package" ShapeID="_x0000_i1025" DrawAspect="Icon" ObjectID="_1352572164" r:id="rId5"/>
</w:object>
</w:r>
</w:p>
The o:OLEObject contains a reference to the OleObjectBinaryPart; you need to set the rel id so it matches
The rest is the image the user sees on the document surface. It may be optional (you could try removing it and see what happens), but if you keep it, note that it refers to an image:
- Code: Select all
<v:imagedata r:id="rId4" o:title=""/>
so you'd need that as well.