SEND PHOTO

verluc

Well-known Member
Joined
Mar 1, 2002
Messages
1,451
Is it possible to mail a photo from excel?
I have a photo in a sheet and want this to send via e-mail.?
Many thanks for a tip
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
If you're using Outlook, check out Ron DeBruin's suggestions.

http://www.rondebruin.nl/sendmail.htm

Specifically this:

'You can add other files also like this
'.Attachments.Add ("C:\test.txt")

If you're using a different e-mail client, posty back with what you're using.

Hope that helps.

Smitty
 
Upvote 0
Thanks Pennysaver,but I want this to do without an attachments,because most people don't like attachments.The body of my mail must be the photo

Many thanks
 
Upvote 0
Hi Verluc

here is some code adapted from my page here;

http://www.xcelfiles.com/Outlook_Chart.html

<pre><FONT COLOR="#00007F">Option</FONT> <FONT COLOR="#00007F">Explicit</FONT>


<FONT COLOR="#007F00">'To create an HTML message that included an embedded image -- that, instead,</FONT>
<FONT COLOR="#007F00">'all "" <img> "" tags had to use full URLs to public web addresses.</FONT>
<FONT COLOR="#007F00">'The impossible has become possible, though, through the efforts of Outlook MVP Neo,</FONT>
<FONT COLOR="#007F00">'who devised a method that uses undocumented MAPI properties and CDO.</FONT>

<FONT COLOR="#007F00">'CDO = Microsoft® Collaboration Data Objects</FONT>
<FONT COLOR="#007F00">'CDO does not represent a new messaging model, but rather an additional scripting interface</FONT>
<FONT COLOR="#007F00">'to the Messaging Application Programming Interface (MAPI) model.</FONT>

<FONT COLOR="#007F00">'for more info see;</FONT>
<FONT COLOR="#007F00">'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdo/html/_olemsg_overview_of_cdo.asp</FONT>

<FONT COLOR="#007F00">'For versions see;</FONT>
<FONT COLOR="#007F00">'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncdsys/html/cdo_roadmap.asp</FONT>

<FONT COLOR="#007F00">'In VBA or Visual Basic you will need to add a reference to the CDO 1.21 library to use this procedure.</FONT>
<FONT COLOR="#007F00">'For client applications, you should install Outlook in order to install CDO.</FONT>
<FONT COLOR="#007F00">'In Outlook 2000 and Outlook 2002, CDO is included, but you must explicitly select</FONT>
<FONT COLOR="#007F00">'it during setup.</FONT>

<FONT COLOR="#007F00">'Microsoft CDO 1.21 Library</FONT>
<FONT COLOR="#007F00">'MAPI</FONT>
<FONT COLOR="#007F00">'GUID = {3FA7DEA7-6438-101B-ACC1-00AA00423326}</FONT>
<FONT COLOR="#007F00">'Path C:\PROGRA~1\COMMON~1\System\Mapi\1033\NT\CDO.DLL</FONT>
<FONT COLOR="#007F00">'GUID Ref .AddFromGuid "{3FA7DEA7-6438-101B-ACC1-00AA00423326}",1,21</FONT>
<FONT COLOR="#007F00">'.Item("MAPI")</FONT>


<FONT COLOR="#00007F">Sub</FONT> InsertPictureInEmail_V1()
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Ivan F Moala 17th March 2003</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Amendment</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Ivan F Moala 30th June 2003</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Thanks to Outlook MVP Neo</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Original used "<img src=" image full address</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> So the image had to have a url web address to</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> be viewed properly</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Testing under Xl2000 / WinXP</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Dimension variables, lets use Latebinding</FONT>
<FONT COLOR="#00007F">Dim</FONT> oOutlookApp <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>
<FONT COLOR="#00007F">Dim</FONT> oOutlookMessage <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>
<FONT COLOR="#00007F">Dim</FONT> oFSObj <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>
<FONT COLOR="#00007F">Dim</FONT> strHTMLBody <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">String</FONT>
<FONT COLOR="#00007F">Dim</FONT> strTempFilePath <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">String</FONT>
<FONT COLOR="#00007F">Dim</FONT> oOutlookAppAttach <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>
<FONT COLOR="#00007F">Dim</FONT> oOutlook_Att <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>
<FONT COLOR="#00007F">Dim</FONT> strEntryID <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">String</FONT>
<FONT COLOR="#00007F">Dim</FONT> oSession <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Use Early binding = Reference CDO</FONT>
<FONT COLOR="#00007F">Dim</FONT> oMsg <FONT COLOR="#00007F">As</FONT> MAPI.Message
<FONT COLOR="#00007F">Dim</FONT> oAttachs <FONT COLOR="#00007F">As</FONT> MAPI.Attachments
<FONT COLOR="#00007F">Dim</FONT> oAttach <FONT COLOR="#00007F">As</FONT> MAPI.Attachment
<FONT COLOR="#00007F">Dim</FONT> colFields <FONT COLOR="#00007F">As</FONT> MAPI.Fields
<FONT COLOR="#00007F">Dim</FONT> oField <FONT COLOR="#00007F">As</FONT> MAPI.Field
<FONT COLOR="#00007F">Dim</FONT> ID <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Object</FONT>
<FONT COLOR="#00007F">Dim</FONT> objPict <FONT COLOR="#00007F">As</FONT> Shape
<FONT COLOR="#00007F">Dim</FONT> MyChart <FONT COLOR="#00007F">As</FONT> Chart
<FONT COLOR="#00007F">Dim</FONT> Pict <FONT COLOR="#00007F">As</FONT> Shape
<FONT COLOR="#00007F">Dim</FONT> blnPict <FONT COLOR="#00007F">As</FONT> <FONT COLOR="#00007F">Boolean</FONT>


<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> You need to run this in the Sheet that has the Image!</FONT>
<FONT COLOR="#00007F">For</FONT> Each Pict In ActiveSheet.Shapes
<FONT COLOR="#00007F">If</FONT> Pict.Type = 13 <FONT COLOR="#00007F">Then</FONT>
<FONT COLOR="#00007F">If</FONT> MsgBox("Email this Picture:= " & Pict.Name & vbCr & _
"Use this ? ", vbYesNo) = vbYes <FONT COLOR="#00007F">Then</FONT>
<FONT COLOR="#00007F">Set</FONT> objPict = ActiveSheet.Shapes(Pict.Name)
blnPict = <FONT COLOR="#00007F">True</FONT>
<FONT COLOR="#00007F">Exit</FONT> <FONT COLOR="#00007F">For</FONT>
<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">If</FONT>
<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">If</FONT>
<FONT COLOR="#00007F">Next</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Make sure that an Image is set</FONT></FONT></FONT></FONT>
<FONT COLOR="#00007F">If</FONT> Not blnPict <FONT COLOR="#00007F">Then</FONT>
MsgBox "No Picture selected!"
<FONT COLOR="#00007F">Exit</FONT> <FONT COLOR="#00007F">Sub</FONT>
<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">If</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT>
<FONT COLOR="#007F00">'Get the temp folder path</FONT>
<FONT COLOR="#00007F">Set</FONT> oFSObj = CreateObject("Scripting.FilesystemObject")

strTempFilePath = oFSObj.GetSpecialFolder(2)
strTempFilePath = strTempFilePath & "\MyImg.gif"

<FONT COLOR="#00007F">With</FONT> objPict
.CopyPicture 1, 2
<FONT COLOR="#00007F">Set</FONT> MyChart = ActiveSheet.ChartObjects.Add(1, 1, .Width + 8, .Height + 8).Chart
<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">With</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Export the chart. We'll use it later</FONT>
<FONT COLOR="#00007F">With</FONT> MyChart
.Paste
.Export strTempFilePath
.Parent.Delete
<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">With</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT>
<FONT COLOR="#007F00">'Create an instance of Outlook (or use existing instance if it already exists</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlookApp = CreateObject("Outlook.Application")

<FONT COLOR="#007F00">'Create a mail item</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlookMessage = oOutlookApp.CreateItem(0)
<FONT COLOR="#00007F">Set</FONT> oOutlookAppAttach = oOutlookMessage.Attachments
<FONT COLOR="#007F00">' add graphic as attachment to Outlook message</FONT>
<FONT COLOR="#007F00">' change path to graphic as needed</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlook_Att = oOutlookAppAttach.Add(strTempFilePath)

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Lets save the msg, this is so that the EntryID property</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> is set.</FONT>
oOutlookMessage.Close olSave

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Lets get the unique entry ID of the object.</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> EntryID property corresponds to the MAPI property PR_ENTRYID.</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> MAPI systems assign a permanent, unique ID string when an object</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> is created that does not change from one MAPI session to another.</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Also, the EntryID changes when an item is moved into another folder.</FONT>
strEntryID = oOutlookMessage.EntryID

<FONT COLOR="#00007F">Set</FONT> oOutlookMessage = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#007F00">' *** POSITION CRITICAL *** you must dereference the</FONT>
<FONT COLOR="#007F00">' attachment objects before changing their properties</FONT>
<FONT COLOR="#007F00">' via CDO</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlookAppAttach = <FONT COLOR="#00007F">Nothing</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> initialize CDO session</FONT>
<FONT COLOR="#00007F">On</FONT> <FONT COLOR="#00007F">Error</FONT> <FONT COLOR="#00007F">Resume</FONT> <FONT COLOR="#00007F">Next</FONT>
<FONT COLOR="#00007F">Set</FONT> oSession = CreateObject("MAPI.Session")
oSession.Logon "", "", <FONT COLOR="#00007F">False</FONT>, <FONT COLOR="#00007F">False</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> get the message created earlier</FONT>
<FONT COLOR="#00007F">Set</FONT> oMsg = oSession.GetMessage(strEntryID)

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> set properties of the attached graphic that make</FONT>
<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> it embedded and give it an ID for use in an <IMG> tag</FONT>
<FONT COLOR="#00007F">Set</FONT> oAttachs = oMsg.Attachments
<FONT COLOR="#00007F">Set</FONT> oAttach = oAttachs.Item(1)
<FONT COLOR="#00007F">Set</FONT> colFields = oAttach.Fields

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> <FONT COLOR="#00007F">Set</FONT> oField = oFieldsColl.Add (name, Class [, value] [, PropsetID] )</FONT>
<FONT COLOR="#00007F">Set</FONT> oField = colFields.Add(CdoPR_ATTACH_MIME_TAG, "image/gif")
<FONT COLOR="#00007F">Set</FONT> oField = colFields.Add(&H3712001E, "MyIdent")

oMsg.Fields.Add "{0820060000000000C000000000000046}0x8514", 11, <FONT COLOR="#00007F">True</FONT>
oMsg.Update

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> Here put any HTML you want - this is just an example</FONT>
strHTMLBody = "This is the Image you were looking for.
"
strHTMLBody = strHTMLBody & "<FONT COLOR="#00007F">Get</FONT> back to me ASAP
"
strHTMLBody = strHTMLBody & "Looking forward to your reply.


"
strHTMLBody = strHTMLBody & "Ivan F Moala

<hr>"

<FONT COLOR="#007F00">' get the Outlook MailItem again</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlookMessage = oOutlookApp.GetNamespace("MAPI").GetItemFromID(strEntryID)

<FONT COLOR="#007F00">' add HTML content -- the <IMG> tag</FONT>
<FONT COLOR="#00007F">With</FONT> oOutlookMessage
.HTMLBody = strHTMLBody & "<IMG align=baseline border=0 hspace=0 SRC=cid:MyIdent>"
.Close (olSave)
.Display
<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">With</FONT>

<FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00"><FONT COLOR="#007F00">'//</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT> cleanup</FONT>
<FONT COLOR="#00007F">Set</FONT> oFSObj = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> oField = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> colFields = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> oMsg = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> oAttachs = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> oAttach = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> colFields = <FONT COLOR="#00007F">Nothing</FONT>

oSession.Logoff

<FONT COLOR="#00007F">Set</FONT> oSession = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlookApp = <FONT COLOR="#00007F">Nothing</FONT>
<FONT COLOR="#00007F">Set</FONT> oOutlookMessage = <FONT COLOR="#00007F">Nothing</FONT>

Kill strTempFilePath

<FONT COLOR="#00007F">End</FONT> <FONT COLOR="#00007F">Sub</FONT></pre>
 
Upvote 0
Hi Ivan,

I use now the macro from Daniel Klann:sending a range of a sheet.That range of a sheet is my photo,but when sending it,I get not the picture but a X in the left uppercorner of my mail.(in the body of my mail)
How can I get the picture?
Many thanks
 
Upvote 0

Forum statistics

Threads
1,221,776
Messages
6,161,870
Members
451,727
Latest member
tyedye4

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top