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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
shree909
Partner - Specialist II
Partner - Specialist II

Passing Variables into Macro to open outlook

Hi Folks , I have a scenario where i want to pass  the list of variables into macro.

I want to add an email to macro, so when the user clicks on the button it should open the outlook with the provided email.

This works fine, now i want to pass these emails by a variable . How can i acheive that.

Here is the Macro :

Sub OpenOutlook()

dim objOutlk 'Outlook

dim objMail 'Email item

dim strMsg

const olMailItem = 0

'Create a new message

  set objOutlk = createobject("Outlook.Application")

  set objMail = objOutlk.createitem(olMailItem)

  objMail.To = "abc@ xyz.com"  ' Here i am passing the email address manually , how can i pass with a variable

  objMail.cc = "" 'Enter an address here to include a carbon copy; bcc is for blind carbon copy's

'Set up Subject Line

  'objMail.subject = "I hope this helps!! "

'Add the body

  strMsg = "Good luck" & vbcrlf

  'To add an attachment, use:

  'objMail.attachments.add("C:\MyAttachmentFile.txt")

  objMail.body = strMsg

  objMail.display 'Use this to display before sending, otherwise call objMail.Send to send without reviewing

'Clean up

set objMail = nothing

set objOutlk = nothing

End sub

Thanks

2 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi shree,

have you thought about doing this as a mailto link instead of using a macro?

alternatively add this to your macro code

set macroVariable = ActiveDocument.GetVariable("yourVariableName")

then use marcroVariable.GetContent.String to retrieve the variable's contents

Marcus

shree909
Partner - Specialist II
Partner - Specialist II
Author

Thanks for the response,

can you please provide a sample file with working..

Thanks