Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

macro send email to multiple to

hye,

i am trying to send in the macro a email to a few recipients that have differents domains ( like one gmail, one hotmail,...) , how can i do it?

here is what works till now:

SET objMsg = CreateObject("CDO.Message")

SET msgConf = CreateObject("CDO.Configuration")

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=X

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "ASPMX.L.GOOGLE.COM"

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=XX

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=X

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = X

msgConf.Fields.Update

objMsg.To="XXXX@gmail.com"

objMsg.From="yyy@gmail.com"

objMsg.Subject="liste"

objMsg.HTMLBody="Bonjour"

objMsg.AddAttachment "C:\xxxx.xlsx"

SET objMsg.Configuration = msgConf

objMsg.Send

thanks for your help.

6 Replies
dgreenberg
Luminary Alumni
Luminary Alumni

Can't you just say:

objMsg.To="XXXX@gmail.com;xxx@hotmail.com;xxx@yahoo.com"

Anonymous
Not applicable
Author

no it's not working if its not the same domain (like one hotmail one gmail for example),  any other ideas??

marcus_sommer

The suggestion from dgreenberg worked - I do such things since years. If it's not worked for you there are probably some little syntax-issues. You might need additionally spaces between the adresses and instead the semi-colon as delimiter a colon - if there is only one error the whole routine will fail.

Further possible is that your used mail-server blocked this behaviour and/or needs some other configurations respectively licences.

- Marcus

Anonymous
Not applicable
Author

no its not working.

i tried with and without spaces and the problem is still here

dgreenberg
Luminary Alumni
Luminary Alumni

This works like a charm for me.  SMTP server and email addresses have been changed to protect the innocent   it could possibly be a Google specific email issue I would search gmail SMTP outside of the QV realm.

sub myMail

  SET objMsg = CreateObject("CDO.Message")

  SET msgConf = CreateObject("CDO.Configuration")

  msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2

  msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")= "smtperver.goeshere.com"

  msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25

  'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=X

  'msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = X

  

  msgConf.Fields.Update

  objMsg.To="danielgreenberg@xyz.com;dan@yzx.com"

  objMsg.From="danielgreenberg@xyz.com"

  objMsg.Subject="Testing email"

  objMsg.HTMLBody="if you get this just let me know.  Thanks Dan"

  SET objMsg.Configuration = msgConf

  objMsg.Send

end sub

dgreenberg
Luminary Alumni
Luminary Alumni

It is also possible that the gmail smtp server blocks relaying to domains outside of gmail.  This isn't the case when using the gmail client but could very well be the case when using the google smtp server. 

One thing google search did turn up for me is a limit as to how many emails a day you can send via smtp but I don't think you are hitting that limit.