Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
Thanks for the response,
can you please provide a sample file with working..
Thanks