I am using a macro to store the objects to JPG and then send those files to the recipients you want as an embebed image on the mail body.
The macro is :
Sub Init
Set Button1 = ActiveDocument.GetSheetObject("OBJECTID_HERE")
'Make a button on the designer and
Button1.Press
end Sub
sub CreaObjetos
ActiveDocument.reload
ActiveDocument.GetApplication.Sleep 2000
ActiveDocument.Save
ExpJPG "TX213","Logo"
ExpJPG "CH218 Sales","GraphSales"
PrepareReports
End sub
Sub PrepareReports
ExportEmail "One.person@domainx.com"
'ExportEmail "other.person@domainx.com"
ActiveDocument.Save
ActiveDocument.GetApplication.Quit
end sub
'-------------------------------------------------------------------------------------------------
SUB setVariable(varName, varValue)
set v = ActiveDocument.Variables(varName)
v.SetContent varValue, true
END SUB
Sub ExpJPG(ObjId,ResName)
Set Objeto = ActiveDocument.GetSheetObject(ObjId)
Objeto.ExportBitmapToFile "C:\dashboards\email\"& ResName &".jpg"
end Sub
Sub ExportEmail(Correo)
Dim objEmail
Const cdoSendUsingPort = 2 'Send the message using SMTP
Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 ' basic (clear-text) authentication
Const cdoNTLM = 2 ' NTLM
Const SMTPServer = "mail.domainx.com" ' changed for public consumption
Const SMTPPort = 25 ' Port number for SMTP
Const SMTPTimeout = 120 ' Timeout for SMTP in seconds
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Business.Intelligence@solmar.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = your_pwd_here"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTPServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = SMTPTimeout
.Update
End With
objEmail.To = Correo '"sender.person@domainx.com" 'Aqui sera Correo
objEmail.From = "sender.person@domainx.com"
objEmail.Subject = "Report Name Here"
HTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & chr(13) & chr(10)
HTML = HTML & "<html>"
HTML = HTML & "<head>"
HTML = HTML & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">"
HTML = HTML & "<title>Title here</title>"
HTML = HTML & "</head>"
HTML = HTML & "<body bgcolor=""#FFFFFF"">"
'-------------------------------------------------------------------------------------------------------
HTML = HTML & "<table border=""1"" cellpadding=""1"" cellspacing=""1"">"
HTML = HTML & " <tr>"
HTML = HTML & " <td align=""center"" ><img src=""cid:Logo.jpg"" ></td>"
HTML = HTML & " </tr>"
HTML = HTML & "</table>"
HTML = HTML & "<br><img src=""cid:GraphSales.jpg"" >"
HTML = HTML & "</body>"
HTML = HTML & "</html>"
'===============================================================================================================================
Set objBP = objEmail.AddRelatedBodyPart("C:\dashboards\email\Logo.jpg", "Logo.jpg", CdoReferenceTypeName)
objBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<Logo.jpg>"
objBP.Fields.Update
Set GraphObj= objEmail.AddRelatedBodyPart("C:\dashboards\email\GraphSales.jpg", "GraphSales.jpg", CdoReferenceTypeName)
GraphObj.Fields.Item("urn:schemas:mailheader:Content-ID") = "<TxtRojo.jpg>"
GraphObj.Fields.Update
objEmail.HTMLBody = HTML
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
End Sub
' ---------------------------------------------------------------------------------------------------------------------------------------------------------
Please let me know if you need more help on this.
Regards