Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Email sending not working

Why this this function not working?

function sending()
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Subject"
objMessage.From = "test1@gmail.com"
objMessage.To = "test2@gmail.com"

objMessage.TextBody = "Body"

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

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"


objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername ") ="test1@gmail.com"

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword ") ="password"

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

objMessage.Configuration.Fields.Update

objMessage.Send
end function

32 Replies
Alexander_Thor
Employee
Employee

Usually refers to an network error. Reyling allowed on the smtpserver? Try with IP-adress instead of DNS name. Make sure it's the correct port for the smtp server.

Please note that you are creating a CDO-object so you need to have collaboration data objects installed on the machine running the macro. I'm not 100% sure on this but I believe MS stopped shipping CDO since Outlook 2007 so you would need to manually install it.

Not applicable
Author

Hi there,

I tried following script. But all the time I am getting error "ActiveX component can't create object: 'CDO.Message' ".

Can anybody please tell me URGENTLY what is going wrong ??

Sub SendGMail()

' Object creation
Set objMsg = CreateObject("CDO.Message")
Set msgConf = CreateObject("CDO.Configuration")

' Server Configuration
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "user@gmail.com"
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
msgConf.Fields.Update

' Email
objMsg.To = "user@gmail.com"
objMsg.From = "fromuser@domain.com"
objMsg.Subject = "Test send with Gmail account"
objMsg.HTMLBody = "HTML/Plain text message."
objMsg.Sender = "Mr. Name"

Set objMsg.Configuration = msgConf

' Send
objMsg.Send

' Clear
Set objMsg = nothing
Set msgConf = nothing

End Sub

eliran
Creator III
Creator III

Try this command to register the CDO ActiveX

regsvr32 "c:\windows\system32\cdosys.dll"

from a command prompt "run as administrator" (i.e. elevated).

Miguel_Angel_Baeyens

Hi,

Apart from that, did you set your module security to Allow System Access?

Hope that helps.

Miguel

Not applicable
Author

Hi,

I'm trying to send email from an address in the domain of my company to an outside address (in another domain but also on address like gmail or yahoo...). I tried your solution (and many others !) but I haven't find the good solution.

(The same macro works well to send email in the same domain and from a GMail account to other address)

Does someone find the solution ?

Thank you,

Pauline

Alexander_Thor
Employee
Employee

I'm guessing you are running into relay problems.

Usually you can debug it by open up a telnet promp and try to send the same e-mail, you will get some more detailed error information.

By default you aren't allow to relay e-mails of your exchange smtp server to outside domains so this is likely something you need to turn on.

Not applicable
Author

The code works perfectly. However, it is using schema.microsoft .... where my scenario is, the server has blocked internet access, besides sending the mail to exchange server (within the same domain). Is there any reference on macro, for sending mail using SMTP to exchange server? I have tested the SMTP mail through QMC, it works though.

Not applicable
Author

I sent from gmail domain to hotmail domain.

It's working!!

Thank you for your code!!!!

Not applicable
Author

hello everyone...Code is working fine....But when we are sending to users from domains......how do we know there passwords....

Not applicable
Author

I'm having some of the same issues.. Can someone please attach a .qvw example that I can open to see how to set this up? Thanks in advance.