Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi ,
Is there any way we can copy the Chart image in the Email body the image should not be an attachment
it should be copied in the Body of mail .It's easy to copy the image but the code for pasting the image is
not seem to be working
Reply Guys
Guys any suggestion
Hi Qliksus,
Were you bale to do this? If yes please share how you did it?
Thanks,
Rajesh Vaswani
Hi,
this is the code to copy image in the email body
sub sendMailTest()
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 = "smtp.iconresources.com"
Const SMTPPort = 25 ' Port number for SMTP
Const SMTPTimeout = 60 ' Timeout for SMTP in seconds
'Sending mail
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
'---------------------------------------------------------------------
' SMTP server details
.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
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "aa"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "bb"
.Update
'---------------------------------------------------------------------
End With
objEmail.MimeFormatted = True
objEmail.To = "aa@aaa.com"
objEmail.Cc = "bb@aa.com"
objEmail.From = "aa@aaa.com"
objEmail.Subject = "Email Sent Through Macro"
vImage = "C:\Users\Saravanan\Desktop\testimage.jpg" // path of the image to be pasted in the email body
objEmail.AddRelatedBodyPart vImage, testimage.jpg, 1 //the 2nd paramerter should be same as the imagename
set Objbody = <html> <body> <img src = "cid:testimage.jpg"> </body> </html>
Objemail.htmlbody = Objbody
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
msgbox ("Test Mail Sent")
end sub
Hi,
do you ever try it?
can the picture show on the body?
Thanks,
hi qliksus,
what you mean is a chart object from browser and paste it as an image to email right?
To do that, use this simple trick.
Right click on the object, click "Print..." then a popup message(Print Object) will appear (it may different, but in standard settings normally this will appear).
After you click "Print.." a new tab/window will appear, now you have your object in this new tab/window then right click to show the menu, you can copy as an image or directly send as an email, depend on what browser you were using.
If there's no new tab/windows appear then you must allow for the new tab/windows to appear in the browser setting or click "press here" in the "print object" popup message.
So now you can paste it as an image to the body of email or any app. like power point or excel and else..
I will not recommend to use a macro because its unstable(depends on the browser), may reduce qv performance, and hard to maintain, etc.
Use macro only if there's no other solutions
hope it help..
Hi,
I use the code below to copy the sheet and attach it in the Mail client
For a button i assign three actions
1) Run Macro - CaptureScreen - to save the screenshot of the sheet and save it in C drive.
2) Launch - select you mail client application
3) Run Macro - Insert image in mail
sub CaptureScreen
ActiveDocument.ActiveSheet.ExportBitmapToFile "C:\Snapshot.PNG"
'msgbox "Screen capture is stored in C:\Snapshot.JPG."
end sub
sub InsertImageInMail
ActiveDocument.GetApplication.Sleep 2000
Set objShell = CreateObject("WScript.Shell")
objShell.SendKeys "%FNM" - short cut keys for attachment
objShell.SendKeys "%IA" --short cut keys for attachment
objShell.SendKeys "C:\Snapshot.PNG"
objShell.SendKeys "{ENTER}"
end sub
Hope this helps you.
Regards,
Jagan.
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
is this same useful in private network? i have own mail service.
i coped this code, but nothing happen.
Hi Guys
This is how you do it.
function SendMail()
Dim objEmail
Const cdoSendUsingPort = 2
Const cdoAnonymous = 0
Const cdoBasic = 1
Const cdoNTLM = 2
Set SMTP = ActiveDocument.GetVariable("SMTPServer")
Set SMTPData = SMTP.GetContent
ActiveDocument.GetApplication.WaitForIdle
SMTPServer = SMTPData.String
userName = "xxx@xxx.co.za"
userPassword = "password"
Const SMTPPort = 25 ' Port number for SMTP
Const SMTPTimeout = 60 ' Timeout for SMTP in seconds
'Sending mail
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
'---------------------------------------------------------------------
' SMTP server details
.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") = cdoAnonymous
.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
Set EmailTo = ActiveDocument.GetVariable("EmailTo")
Set EmailToData = EmailTo.GetContent
objEmail.To = EmailToData.String
ActiveDocument.GetApplication.WaitForIdle
Set EmailFrom = ActiveDocument.GetVariable("EmailFrom")
Set EmailFromData = EmailFrom.GetContent 'Email Recipient
objEmail.From = EmailFromData.String
Set EmailSubject = ActiveDocument.GetVariable("EmailSubject")
Set EmailSubjectData = EmailSubject.GetContent 'Email Sender
objEmail.Subject = EmailSubjectData.String
Set EmailBody = ActiveDocument.GetVariable("EmailBody")
Set EmailBodyData = EmailBody.GetContent ' Subject
objEmail.TextBody = EmailBodyData.String
objEmail.HTMLBODY = "<HTML><BODY><img align=baseline border=0 hspace=0 src='C:\Test.jpg'</BODY></HTML>"
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
msgbox ("Mail Sent")
end function