Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro - Write Email

Hey Guys,

I need help in writing a macro. It will need to open an outlook new message and set the to and subject line. Then the user can enter data in the message and send it.

Something like:

function openMail
Dim Outlook 'As New Outlook.Application
Set Outlook = CreateObject("Outlook.Application")

.To = "kallcorn@us-analytics.com"
.Subject = "Hello"

Set objEmail = Nothing

end function

9 Replies
Not applicable
Author

Found out what I was doing wrong here is the code:

SUB openMail


Set vOlApp = CreateObject("Outlook.Application")
Set vMessage = vOlApp.CreateItem(olMailItem)

vMessage.Subject = "Test"
vMessage.To = "kallcorn@us-analytics.com"

vMessage.Display

END SUB

Not applicable
Author

Dear Kallcorn,

I need the same macro solution. But I want to send the email for more than one email address. The email addresses are in the Email field. How can I modify your macro to send the email for all selected email address on the email fields.

Kind Regards,

Not applicable
Author

Hi Asimakin,

I have done something similar, and here is the code. I read the values from a TableBox, but you should be able to do something similar with a Listbox

MyConcatenatedField= " "

for i = 1 to TableBox.GetRowCount-1

MyConcatenatedField= MyConcatenatedField& TableBox.GetCell(i,1).text & "; "

end if
next

Not applicable
Author

Hi,

I have an error message with the above code. Would you please send a sample qlikview file?

Kind Regards,

haymarketpaul
Creator III
Creator III

Hello

This looks great and i would love to be able to use it but i get the following error message on the CreateObject line

ActiveX component can't create object: 'Outlook.Application'

Do you know how i can resolve this ?  My macro code...

SUB openMail

Set vOlApp = CreateObject("Outlook.Application")

Set vMessage = vOlApp.CreateItem(olMailItem)

'******** Auto fill out email fields ***********

vMessage.Subject = "QlikView Support Request..."

vMessage.To = "paul.nockolds@haymarket.com"

vMessage.CC = "Somebody@Somewhere.com"

vMessage.Display

END SUB

Not applicable
Author

Hello Paul,

This means that you don’t have MS Outlook installed on your PC. You also need to select macro settings as below:

haymarketpaul
Creator III
Creator III

Thanks for the reply

I've definitely got Outlook installed (and open) on my PC and have changed the Security settings as per your image file.

It now works when i click the Test button inside the Edit Module window but nothing happens when i click the button on my dashboard that the RunMacro action is attached to ??

Any ideas?

Not applicable
Author

Hi Paul,

If you can parse the macro successfully you should see the macro name on the left side of the screen:

Then please make sure that you set your button settings as below:

haymarketpaul
Creator III
Creator III

Brilliant thank you

I had the Macro Name in the Button Properties window different to the subroutine name in the edit module window.

It now works perfectly

Thanks again