Guys can you please take a look at the below code and let me know your thoughts. The first bit errors out to runtime error 2147220973 "The transport failed to connect to the server"
The second bit does not throw any error. ( I have opened a watch of every variable and they are all filling out fine) but the message will not deliver to the specified email address
I had to include the On Error Resume next line because while the delete in the loop was running it eventually errored out after the 6th go saying "the item could not be found in the specified list".
I think this had to do with it actioning a delete command on the iconf property and it could not find one of the items to delete a value from. Fast foward that, I get to the imsg variable and all properties are completing fine but not sending through the message.
Do you have any ideas on what I might be doing wrong?
Code:
'This code is courtesy of Ron de Bruin [URL="http://www.rondebruin.nl/cdo/htm"]www.rondebruin.nl/cdo/htm[/URL]
'The code will send an automated email to the ticket owner advicing closure (code has been modified for Intercall)
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
iConf.Load -1 ' CDO Source Defaults
'Sets up relevant fields
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusing[/URL]") = cdoSendUsingPort
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserver[/URL]") = "someipaddress"
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserverport[/URL]") = 25
iConf.Fields.Update
End With
strbody = "Hi Franklyn" & "," & vbNewLine & vbNewLine & _
"Your Intercall ticket is now closed. Please refer to the ticket details if you have any questions." & vbNewLine & _
" " & vbNewLine & _
"We also appreciate any feedback you may have. Please log into Intercall and click the submit feedback button to send this through." & vbNewLine & _
" " & vbNewLine & _
"Thank you and regards" & vbNewLine & _
" " & vbNewLine & _
"DSN TEL: 475-8443" & vbNewLine & _
"FAX: 475-7050" & vbNewLine & _
"EMAIL: [EMAIL="MISHELPDESK@eur.army.mil"]someemail[/EMAIL]address" & vbNewLine & _
"MIS Website: [EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address[URL="https://portal.eur.army.mil/sites/IMCOM-E-G/fmwr/nafsm/mis/default.aspx"]sites/IMCOM-E-G/fmwr/nafsm/mis/default.aspx[/URL]" & vbNewLine & _
""
With iMsg
Set .Configuration = iConf
.To = "<[EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address>"
.CC = ""
.BCC = ""
.From = "<[EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address>"
.Subject = "Intercall ticket number" & " " & Form_FaultReview.txtid
.TextBody = strbody
.Send
End With
The second bit does not throw any error. ( I have opened a watch of every variable and they are all filling out fine) but the message will not deliver to the specified email address
Code:
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
Dim nResetIndex
For nResetIndex = 0 To iConf.Fields.Count
On Error Resume Next
iConf.Fields.Delete nResetIndex
Next
iConf.Load -1 ' CDO Source Defaults
'Sets up relevant fields
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/sendusing[/URL]") = cdoSendUsingPort
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserver[/URL]") = "someipaddress"
.Item("[URL]http://schemas.microsoft.com/cdo/configuration/smtpserverport[/URL]") = 25
iConf.Fields.Update
End With
strbody = "Hi Franklyn" & "," & vbNewLine & vbNewLine & _
"Your Intercall ticket is now closed. Please refer to the ticket details if you have any questions." & vbNewLine & _
" " & vbNewLine & _
"We also appreciate any feedback you may have. Please log into Intercall and click the submit feedback button to send this through." & vbNewLine & _
" " & vbNewLine & _
"Thank you and regards" & vbNewLine & _
" " & vbNewLine & _
"DSN TEL: 475-8443" & vbNewLine & _
"FAX: 475-7050" & vbNewLine & _
"EMAIL: [EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address" & vbNewLine & _
"MIS Website: [EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address[URL="https://portal.eur.army.mil/sites/IMCOM-E-G/fmwr/nafsm/mis/default.aspx"]/sites/IMCOM-E-G/fmwr/nafsm/mis/default.aspx[/URL]" & vbNewLine & _
""
With iMsg
Set .Configuration = iConf
.To = "<[EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address>"
.CC = ""
.BCC = ""
.From = "<[EMAIL="MISHELPDESK@eur.army.mil"][COLOR=#0066cc]someemail[/COLOR][/EMAIL]address>"
.Subject = "Intercall ticket number" & " " & Form_FaultReview.txtid
.TextBody = strbody
.Send
End With
I had to include the On Error Resume next line because while the delete in the loop was running it eventually errored out after the 6th go saying "the item could not be found in the specified list".
I think this had to do with it actioning a delete command on the iconf property and it could not find one of the items to delete a value from. Fast foward that, I get to the imsg variable and all properties are completing fine but not sending through the message.
Do you have any ideas on what I might be doing wrong?