Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

E-mail sending not working ( The message could not be sent to the SMTP server. The transport error code was 0x80040217)

Hi Experts,

I am getting an error "The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available" on on code line 'objMsg.Send'.

Below is my Code:

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") = 25  

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

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "satyendrabelwanshi805@gmail.com"  

msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "satyendrab@z45"  

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

msgConf.Fields.Update

' Email

objMsg.To = "sumantdiwakar@gmail.com"  

objMsg.From = "satyendrabelwanshi805@gmail.com"  

objMsg.Subject = "Test send with gmail account"

objMsg.HTMLBody = "Hello!!"

objMsg.Sender = "Mr. Satyendra"

Set objMsg.Configuration = msgConf

' Send

objMsg.Send

' Clear

Set objMsg = nothing

Set msgConf = nothing

End Sub

*****

Thanks for your help & support

Satyendra

1 Solution

Accepted Solutions
parul_mehta
Partner - Creator
Partner - Creator

  Can you try this; I have used this to send straight table report in form of excel to my mailbox.

and to write the same report to folder as well.

configure a variable EmailAddress with your mail ID

sub ExcelFile

 

Set v = ActiveDocument.Variables ("EmailAddress")

Email=v.GetContent.String

'Path = "C:\temp\"

Path = "C:\Users\parul_mehta\Documents\LR\Temp\"

  FileName = "Test_" & GetFormattedDate  & ".xlsx"

 

set XLApp = CreateObject("Excel.Application")

 

XLApp.Visible = False

  Set XLDoc = XLApp.Workbooks.Add

 

ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

 

XLDoc.Sheets(1).Paste()

 

XLDoc.Sheets(1).Columns("A:D").EntireColumn.AutoFit

 

XLDoc.Sheets(1).Columns("A:A").ColumnWidth = 15.57

 

XLDoc.Sheets(1).Columns("B:B").ColumnWidth = 12.43

 

XLDoc.Sheets(1).Columns("C:C").ColumnWidth = 15.29

 

XLDoc.Sheets(1).Columns("D:D").ColumnWidth = 15.57

 

XLDoc.Sheets(1).Name = "Export"

 

XLDoc.SaveAs Path & FileName

 

XLApp.Quit

 

 

Set myApp = CreateObject ("Outlook.Application")

 

Set myMessage = myApp.CreateItem(olMailItem)

 

myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText

 

myMessage.To = Email

 

' myMessage.Attachments.Add "C:\temp\" & FileName

 

myMessage.Attachments.Add "C:\Users\parul_mehta\Documents\LR\Temp\" & FileName

 

myMessage.Subject = "Test File " & Date()

 

myMessage.Send

 

Set myMessage = Nothing

 

Set myApp = Nothing

 

Set myInspector = Nothing

 

Set myDoc = Nothing

 

end sub

 

View solution in original post

11 Replies
stabben23
Partner - Master
Partner - Master

Try With this change.


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

Anonymous
Not applicable
Author

Hi Staffan,

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


Result Outcomes : The transport failed to connect to the server.

stabben23
Partner - Master
Partner - Master

Ok, It could be some setting With the Google account.

I'll think you need to give qlikview app Access to the account or something simular.

stabben23
Partner - Master
Partner - Master

Anonymous
Not applicable
Author

Hi Staffan,

Thanks for your support , but problem is remain same

parul_mehta
Partner - Creator
Partner - Creator

  Can you try this; I have used this to send straight table report in form of excel to my mailbox.

and to write the same report to folder as well.

configure a variable EmailAddress with your mail ID

sub ExcelFile

 

Set v = ActiveDocument.Variables ("EmailAddress")

Email=v.GetContent.String

'Path = "C:\temp\"

Path = "C:\Users\parul_mehta\Documents\LR\Temp\"

  FileName = "Test_" & GetFormattedDate  & ".xlsx"

 

set XLApp = CreateObject("Excel.Application")

 

XLApp.Visible = False

  Set XLDoc = XLApp.Workbooks.Add

 

ActiveDocument.GetSheetObject("CH01").CopyTableToClipboard true

 

XLDoc.Sheets(1).Paste()

 

XLDoc.Sheets(1).Columns("A:D").EntireColumn.AutoFit

 

XLDoc.Sheets(1).Columns("A:A").ColumnWidth = 15.57

 

XLDoc.Sheets(1).Columns("B:B").ColumnWidth = 12.43

 

XLDoc.Sheets(1).Columns("C:C").ColumnWidth = 15.29

 

XLDoc.Sheets(1).Columns("D:D").ColumnWidth = 15.57

 

XLDoc.Sheets(1).Name = "Export"

 

XLDoc.SaveAs Path & FileName

 

XLApp.Quit

 

 

Set myApp = CreateObject ("Outlook.Application")

 

Set myMessage = myApp.CreateItem(olMailItem)

 

myMessage.BodyFormat = 3 'Outlook.OlBodyFormat.olFormatRichText

 

myMessage.To = Email

 

' myMessage.Attachments.Add "C:\temp\" & FileName

 

myMessage.Attachments.Add "C:\Users\parul_mehta\Documents\LR\Temp\" & FileName

 

myMessage.Subject = "Test File " & Date()

 

myMessage.Send

 

Set myMessage = Nothing

 

Set myApp = Nothing

 

Set myInspector = Nothing

 

Set myDoc = Nothing

 

end sub

 

stabben23
Partner - Master
Partner - Master

Try to change objMsg.From

objMsg.To = "sumantdiwakar@gmail.com"  

objMsg.From = "satyendrabelwanshi805@gmail.com"   //Change to a valid adress, any

objMsg.Subject = "Test send with gmail account"

objMsg.HTMLBody = "Hello!!"

objMsg.Sender = "Mr. Satyendra"

stabben23
Partner - Master
Partner - Master

Do you allow system Access:

systemaccess.GIF

parul_mehta
Partner - Creator
Partner - Creator

DId this work Satyendra?