Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
pzwonford
New Contributor II

Adding chart & HTML to e-mail

Hi guys, i have the following code

  1. Sub Email_Test
  2. newfile = "C:\Newfile.xls"
  3. EmailBody = "<font face = " & Chr(34) & "Calibri" & Chr(34) & ">Hi, <BR> <BR>" & _
  4.         "<BR> <BR> Please use this link to the new file: <a href=" &_
  5.         Chr(34) & newfile & Chr(34) & ">Click here</a> <BR> </font>"

  6. Set myApp = CreateObject ("Outlook.Application") 
  7. Set myMessage = myApp.CreateItem(olMailItem) 
  8. myMessage.BodyFormat = 2 'HTMLFormat 
  9. myMessage.To = "test@test.com
  10. myMessage.Subject = "New file" 
  11. Set myInspector = myMessage.GetInspector 'add signature to e-mail 
  12. Set myDoc = myInspector.WordEditor 
  13. ActiveDocument.GetSheetObject("CH46").CopyBitmapToClipboard
  14. myDoc.Range(0,0).PasteSpecial False, False, 0, False, 5 
  15. myInspector.WordEditor.Content.InsertBefore chr(13) 
  16. myInspector.WordEditor.Content.InsertBefore chr(13) 
  17. myInspector.WordEditor.Content.InsertBefore EmailBody & chr(13) & chr(13)
  18. myMessage.Display 
  19. Set myMessage = Nothing 
  20. Set myApp = Nothing 
  21. Set myInspector = Nothing 
  22. Set myDoc = Nothing 
  23. End sub



It adds the chart to the body of the e-mail which is great but adds the actual text rather than the html code. Can anyone help me here? I'd like to add the html code and then the chart

1 Solution

Accepted Solutions
Frank_Hartmann
Honored Contributor

Re: Adding chart & HTML to e-mail

try like that:

Sub Email_Test

Set myApp = CreateObject ("Outlook.Application")

Set myMessage = myApp.CreateItem(olMailItem)

    newfile = "C:\Users\Admin\Desktop\123.xlsx"

    myMessage.body = ("EmailBody")

    myMessage.HTMLBODY = "<font face = " & Chr(34) & "Calibri" & Chr(34) & ">Hi, <BR> <BR>" & _

                         "<BR> <BR> Please use this link to the new file: <a href=" &_

                         Chr(34) & newfile & Chr(34) & ">Click here</a> <BR> </font>"

    'myMessage.Attachments.Add("C:\Users\Admin\Desktop\123.xlsx")            'If you want to attach a file

    myMessage.BodyFormat = 2 'HTMLFormat

    myMessage.To = "test@test.com"

    myMessage.Subject = "New file"

    Set myInspector = myMessage.GetInspector 'add signature to e-mail

    Set myDoc = myInspector.WordEditor

    ActiveDocument.GetSheetObject("CH46").CopyBitmapToClipboard

    myDoc.Range(0,0).PasteSpecial False, False, 0, False, 5

    myInspector.WordEditor.Content.InsertBefore chr(13)

    myInspector.WordEditor.Content.InsertBefore chr(13)

    myInspector.WordEditor.Content.InsertBefore EmailBody & chr(13) & chr(13)

    myMessage.Display

    Set myMessage = Nothing

    Set myApp = Nothing

    Set myInspector = Nothing

    Set myDoc = Nothing

End sub

3 Replies
Frank_Hartmann
Honored Contributor

Re: Adding chart & HTML to e-mail

try like that:

Sub Email_Test

Set myApp = CreateObject ("Outlook.Application")

Set myMessage = myApp.CreateItem(olMailItem)

    newfile = "C:\Users\Admin\Desktop\123.xlsx"

    myMessage.body = ("EmailBody")

    myMessage.HTMLBODY = "<font face = " & Chr(34) & "Calibri" & Chr(34) & ">Hi, <BR> <BR>" & _

                         "<BR> <BR> Please use this link to the new file: <a href=" &_

                         Chr(34) & newfile & Chr(34) & ">Click here</a> <BR> </font>"

    'myMessage.Attachments.Add("C:\Users\Admin\Desktop\123.xlsx")            'If you want to attach a file

    myMessage.BodyFormat = 2 'HTMLFormat

    myMessage.To = "test@test.com"

    myMessage.Subject = "New file"

    Set myInspector = myMessage.GetInspector 'add signature to e-mail

    Set myDoc = myInspector.WordEditor

    ActiveDocument.GetSheetObject("CH46").CopyBitmapToClipboard

    myDoc.Range(0,0).PasteSpecial False, False, 0, False, 5

    myInspector.WordEditor.Content.InsertBefore chr(13)

    myInspector.WordEditor.Content.InsertBefore chr(13)

    myInspector.WordEditor.Content.InsertBefore EmailBody & chr(13) & chr(13)

    myMessage.Display

    Set myMessage = Nothing

    Set myApp = Nothing

    Set myInspector = Nothing

    Set myDoc = Nothing

End sub

pzwonford
New Contributor II

Re: Adding chart & HTML to e-mail

Can we add the text and then the chart?

pzwonford
New Contributor II

Re: Adding chart & HTML to e-mail

I got it

myDoc.Range(len(EmailBody),len(EmailBody)).Paste

Thanks for your help again!

Community Browser