
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Macro to paste multiple pictures in the Outlook Email
I have a Qlikview file and I am writting macro to Automate the report generation. I had done the Automation in the form of PowerPoint Presentation. Now I am looking to paste (embed) multiple QV charts in the Outlook email format. I also want to be able to change the position and size of Images.
I am already able to paste one Chart with some text, but now I am looking for pasting multiple charts and formated Text.
sub CreateReport
Set vOlApp = CreateObject("Outlook.Application")
Set vMessage = vOlApp.CreateItem(olMailItem)
ActiveDocument.Sheets("Density").Activate
set image = ActiveDocument.GetSheetObject("CH01")
ActiveDocument.GetApplication.WaitForIdle
image.CopyBitmapToClipboard
vMessage.GetInspector.WordEditor.Range.Paste
vMessage.Subject = "[MTBF] Report"
vMessage.To = "Ppp@yahoo.com"
vMessage.Display
end sub
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This is the code I'm using to paste mulple Qlikview objects into the e-mail
Sub SendMail
Set myApp = CreateObject ("Outlook.Application")
Set myMessage = myApp.CreateItem(olMailItem)
myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText
Supplier = ActiveDocument.Variables("SelectedSupplier").GetContent.String
myMessage.Subject = Supplier & " / Maksukehotus"
call GetPossibleValues ("E-mail 1","strTo",",")
strTo = ActiveDocument.Variables("strTo").GetContent.String
myMessage.To = strTo
Set myInspector = myMessage.GetInspector 'this inserts signature to e-mail
Set myDoc = myInspector.WordEditor
ActiveDocument.GetSheetObject("TX04").CopyTextToClipboard
myText = ActiveDocument.GetSheetObject("TX04").GetText 'this is needed to calculate the lenght of the iserted text to put the next object after it
myDoc.Range(0,0).Paste 'This pastes at the begining of the message body
ActiveDocument.GetSheetObject("CH06").CopyTableToClipboard true
myDoc.Range(len(myText),len(myText)).Paste 'Pastes after the previous text
' myDoc.Range(myDoc.Characters.Count-1, myDoc.Characters.Count).Paste 'Pastes at the end of the message body
' myMessage.GetInspector.WordEditor.Range.Paste 'Replaces the entire message body with clipboard content
' myInspector.WordEditor.Content.InsertAfter chr(13) 'inserts an empty string at the end of the message body content
myMessage.Display
Set myMessage = Nothing
Set myApp = Nothing
Set myInspector = Nothing
Set myDoc = Nothing
end sub

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need to do the same thing. Anyone know how to do this? I think the answer is to reposition the cursor in the message body after pasting each image but I can't figure out how to do that.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
This is the code I'm using to paste mulple Qlikview objects into the e-mail
Sub SendMail
Set myApp = CreateObject ("Outlook.Application")
Set myMessage = myApp.CreateItem(olMailItem)
myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText
Supplier = ActiveDocument.Variables("SelectedSupplier").GetContent.String
myMessage.Subject = Supplier & " / Maksukehotus"
call GetPossibleValues ("E-mail 1","strTo",",")
strTo = ActiveDocument.Variables("strTo").GetContent.String
myMessage.To = strTo
Set myInspector = myMessage.GetInspector 'this inserts signature to e-mail
Set myDoc = myInspector.WordEditor
ActiveDocument.GetSheetObject("TX04").CopyTextToClipboard
myText = ActiveDocument.GetSheetObject("TX04").GetText 'this is needed to calculate the lenght of the iserted text to put the next object after it
myDoc.Range(0,0).Paste 'This pastes at the begining of the message body
ActiveDocument.GetSheetObject("CH06").CopyTableToClipboard true
myDoc.Range(len(myText),len(myText)).Paste 'Pastes after the previous text
' myDoc.Range(myDoc.Characters.Count-1, myDoc.Characters.Count).Paste 'Pastes at the end of the message body
' myMessage.GetInspector.WordEditor.Range.Paste 'Replaces the entire message body with clipboard content
' myInspector.WordEditor.Content.InsertAfter chr(13) 'inserts an empty string at the end of the message body content
myMessage.Display
Set myMessage = Nothing
Set myApp = Nothing
Set myInspector = Nothing
Set myDoc = Nothing
end sub

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Masha,
Yes, this is what I was expecting . Thanks!
Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great, thanks!!!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello! I'm trying to use this code but in my application appears this message in the qlikview's debbuger:
The ActiveX component could not create the 'Outlook.Application' object (this messagem I translated of the portuguese language).
What should I do?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set Requested Module Security option to 'System Access' and Current Local Security to 'Allow System Access' in QV macro editor.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Check your macro security level.
- Brian

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very nice! thanks a lot!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is there any way to attach a pdf file in email?

- « Previous Replies
-
- 1
- 2
- Next Replies »