Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
While using the below code i can able to send a e-mail from Qlikview.
Here i'm trying to do more modifications like now in mail i want to add some body content & signature for the e-mail.
While using the below marco code i can able to achieve the Blue code stuff.. but i'm not able to achieve the red code stuff ..
Help on this..
Qlikview Macro Code:
sub mSendMail
Dim objOutlk 'Outlook
Dim objMail 'Email item
Dim strMsg
dim strMailTo
dim sString
dim oldFormat
Dim Rng
Const olMailItem = 0
Const CdoReferenceTypeName = 1
Set objOutlk = CreateObject("Outlook.Application")
Set objMail = objOutlk.createitem(olMailItem)
Set Rng = Nothing
objMail.To = "abc@xyz.com"
objMail.subject = "Today Dashboard" & Date()
ActiveDocument.ActiveSheet.CopyBitmapToClipboard true
ActiveDocument.GetSheetObject("CH86").ExportBitmapToFile "C:\User\Dashobard.jpeg"
objMail.attachments.add("C:\User\Dashobard.jpeg")
objMail.body ="Please find the Today Dashboard"
strMsg = "This is an automatic generated email from QlikView for Dashobard."
objMail.body = strMsg
objMail.HTMLBODY = "<HTML><BODY><img align=baseline border=0 hspace=10 src='cid:C:\User\Dashobard.jpeg'</BODY></HTML>"
objMail.Send
Set objMail = Nothing
Set objOutlk = Nothing
'Msgbox " Mail delivered"
end sub
Expected output in the E-mail
To:abc@xyz.com
CC:cdf@xyz.com
Subject: todays dashboard.
E-mail body : Hi, Please find the todays dashboard in the attachments.
IMAGE
Email-Signature
Thanks & Regards,
Venkata Sreekanth
I think the problem are the multiple and contrary definings of the mail-body - there are 3 different ones. I suggest to use only one statement like: objMail.HTMLBODY = strMsg whereby your variable then contained the whole body-statement including your needed html-tags and the references to the linked pictures (this path must be available from a receiver point of view and therefore you might any network-path for it and not the local C:).
If and how you could access/choose the proper signature there are outlook-communities a better source whereby you could also set them semi-static with some fix text and variable values from the user who called the routine.
I think this link might be helpful to understand how the HTMLBody could be filled: Send Mail from QlikView with table in the mail body.
- Marcus
Hi Sommer,
Thanks for reply. Yes i agree, i have used this code objMail.HTMLBODY = strMsg cod in my macro. But the problem here is when i received the mail, the body content is not appearing.
Can you suggest me the macro code to get that e-mail body(3) consists the testmessage, Imge & singature.
Thanks in advance..
Thanks & Regards,
Venkata Sreekanth
Had you checked that your variable has really this content which you expect and that there was only one body-statement and that the html has a valid syntax?
- Marcus
Its working properly, but in my generated mail dont have the body content. It is showing only the image
What is the content of the variable strMsg?
- Marcus
strMsg = "This is an automatic generated email from QlikView for Dashobard."
It looked that you yet use several body-statements but it must be only one - maybe something like this:
strMsg = "<HTML><BODY><div>This is an automatic generated email from QlikView for Dashobard.</div><br><br><img align=baseline border=0 hspace=10 src='cid:C:\User\Dashobard.jpeg'</img></BODY></HTML>"
objMail.HTMLBODY = strMsg
- Marcus
Hi Sommer,
Its working now. I cannot able to see the image. As below below like that i can able to see the image in mail body.
I want to view the full image in mail body it self without clicking on the attachments.
You need to enable the option to view your mails in html and also to load pictures automatically - if both is set the picture should be displayed. If not there might be an syntax-error - I suggest to look into various html and outlook communities how a valid syntax looks like - and to make sure that the path to the picture is available from outlook.
- Marcus