Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
Try With this change.
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Hi Staffan,
msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
Result Outcomes : The transport failed to connect to the server.
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.
Check this link
Hi Staffan,
Thanks for your support , but problem is remain same
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
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"
Do you allow system Access:
DId this work Satyendra?