Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Highlighted
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

Tags (4)
1 Solution

Accepted Solutions
MVP
MVP

Re: Email sending not working

For what it's worth, here is the code I'm using with GMail. Tested few minutes ago and working:

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

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

32 Replies
MVP
MVP

Email sending not working

Hi,

You need to add the "Use SSL" as required by Google

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1 ' True will work as well


Hope that helps.

Not applicable

Email sending not working

Thanks, but i still have a problem:

530 5.5.1

http://mail.google.com/support/bin/answer.py?answer=14257

Login and password from gmail account is correct.

MVP
MVP

Re: Email sending not working

For what it's worth, here is the code I'm using with GMail. Tested few minutes ago and working:

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

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable

Email sending not working

Thank you. It is working. Yes

chooco_co
Valued Contributor

Email sending not working

hi all,

how about we send gmail to yahoo? can work?

i already tried if i set the sender from one domain (exchange) to another email (recepient) on the same domain, it can work, but if the recepient on yahoo or different domain. it can't work..

thanks,

Marco

MVP
MVP

Re: Email sending not working

Hello Marco,

It's working fine for me from GMail to Yahoo mail. Anyway, check that the line

objMsg.From = "fromuser@domain.com"

Is properly configured.

If you are using your Exchange server instead of the gmail one, you should check your anti-relay and anti-spam rules, but it doesn't make much sense to me since most of the time mails are sent to people in different domains.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

chooco_co
Valued Contributor

Re: Email sending not working

Hello Miguel,

i try from your script but got an error message "The transport failed to connect to the server."

sub SendEmail(attachment)

          Dim strMailTo

          Dim ObjSendMail

          Set objSelected = ActiveDocument.Fields("EMAILIDS").GetPossibleValues

          if objSelected.Count = 0 then

                    msgbox ("No e-mail reciepient selected")

                    exit sub

          else

                    varSubject = "Report"

                    varTextBody = "Please find report attached"

                    varAttachment = attachment

                    Set ObjSendMail = CreateObject("CDO.Message")

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

                    ObjSendMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "172.16.10.63"

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

                    ObjSendMail.Configuration.Fields.Update

                    ObjSendMail.AddAttachment varAttachment

                    For i = 0 to objSelected.Count-1

                              ObjSendMail.To = objSelected.item(i).Text

                              ObjSendMail.Subject = varSubject

                              ObjSendMail.From = "admin@qlikview.co.id"

                              ObjSendMail.TextBody = varTextBody

                              ObjSendMail.Send

                    next

                    Set ObjSendMail = Nothing

          end if

end sub

this's my code for email exchange..

MVP
MVP

Re: Email sending not working

Hello Mario,

If you take a look at your configuration fields, you are only using three (sendusing, smtpserver and smtpserverport). In my example code above (that is the one I'm using for testing) there are few more, and along them are the user logged into the smtp server (sendusername, sendpassword), what it seems is one of the issues you are having.

Use them in your code with yoour configuration and try again.

Hope that helps.

Miguel Angel Baeyens

BI Consultant

Comex Grupo Ibérica

Not applicable

Re: Email sending not working

Hello Miguel,

                i am getting the same msg  "The transport failed to connect to the server."

i am using exactly same code what you have used in your correct answer.

thanks

Harleen