Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problem mail with macro

Hi all,

I have a problem with automatic emailing some people with a macro.

The problem is getting the local fields to fill in the To-field and picking the right attachement.

In the attached qvw you can see my problem. I hope someone can tell me what i am doing wrong. Here is my code:

Sub Export
rem get Possible Values
set MailListbox = ActiveDocument.GetSheetObject("LB01")
Mails=MailListbox.GetPossibleValues
rem go through Values
for mailcounter = lbound(Mails) to ubound(Mails)
rem clear previous selections
ActiveDocument.ClearAll false
rem Select value
ActiveDocument.Fields("MailID").Select Mails(mailcounter)

rem Action


Set vOlApp = CreateObject("Outlook.Application")
Set vMessage = vOlApp.CreateItem(olMailItem)
Set vToday = ActiveDocument.Variables("vToday")
Set vReport = ActiveDocument.Fields("ReportName").GetSelectedValues
Set vAdress = ActiveDocument.Fields("Adress").GetSelectedValues

vMessage.Subject = "Test"
vMessage.To = vAdress.getcontent.string
vMessage.Attachments.Add("C:\mailtest"&vReport.getcontent.string&vToday.getcontent.string&".pdf")

vMessage.Display
vMessage.send

Next

ActiveDocument.ClearAll false

End Sub

TNX!

0 Replies