A
andy
The below code works great, thank God for many of you who
have helped me. However, I can't seem to delete the file I
am writing to the temporary folder. The code writes to the
folder, then picks up the email attachment from the
folder, but fails at the Kill statement that refers to
that folder and gives the following error: Run-time
error '53' file not found. Yet when I go there the file is
present. Do I have to close something? I tried a wb.close,
but it didn't help.
Public iMsg As Object
Public iConf As Object
Public wb As Workbook
Public WBname As String
Public Location As String
Private Sub btnSubmitForm_Click()
Application.ScreenUpdating = False
Set wb = ThisWorkbook
Location = "http://root.any/temporary/"
WBname = "UtilityForm" & Format(Now, "dd-mm-yy")
& ".xls"
wb.SaveAs Location & WBname
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing"
) = 2
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver
") = "XXX-xx"
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver
port") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.From = """Insite Web Form"" <[email protected]>"
.Subject = "Faser Account Form"
.TextBody = ""
.AddAttachment Location & WBname
.Send
End With
Kill Location & WBname
Set iMsg = Nothing
Set iConf = Nothing
Set WB1 = Nothing
Set WB2 = Nothing
Application.ScreenUpdating = True
End Sub
Thank you in advance
God bless you
have helped me. However, I can't seem to delete the file I
am writing to the temporary folder. The code writes to the
folder, then picks up the email attachment from the
folder, but fails at the Kill statement that refers to
that folder and gives the following error: Run-time
error '53' file not found. Yet when I go there the file is
present. Do I have to close something? I tried a wb.close,
but it didn't help.
Public iMsg As Object
Public iConf As Object
Public wb As Workbook
Public WBname As String
Public Location As String
Private Sub btnSubmitForm_Click()
Application.ScreenUpdating = False
Set wb = ThisWorkbook
Location = "http://root.any/temporary/"
WBname = "UtilityForm" & Format(Now, "dd-mm-yy")
& ".xls"
wb.SaveAs Location & WBname
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item
("http://schemas.microsoft.com/cdo/configuration/sendusing"
) = 2
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver
") = "XXX-xx"
.Item
("http://schemas.microsoft.com/cdo/configuration/smtpserver
port") = 25
.Update
End With
With iMsg
Set .Configuration = iConf
.To = "(e-mail address removed)"
.CC = ""
.BCC = ""
.From = """Insite Web Form"" <[email protected]>"
.Subject = "Faser Account Form"
.TextBody = ""
.AddAttachment Location & WBname
.Send
End With
Kill Location & WBname
Set iMsg = Nothing
Set iConf = Nothing
Set WB1 = Nothing
Set WB2 = Nothing
Application.ScreenUpdating = True
End Sub
Thank you in advance
God bless you