Sending email attachment
Sending email attachment
(OP)
Can somebody please advise me on sending an email attachment using VBs. I've got the following code which I cant get to work. I think it might be that it needs a username and password inserting for it to send via the 1 and 1 SMTP server account. but I don't know where it needs inserting.
DIM fso
Set fso=CreateObject("Scripting.FilesystemObject")
On Error Resume Next
fso.CopyFile "D:\Backup docs1\Zip.zip"
'Wscript.Echo "File copy complete."
strSMTPFrom = "backups@XXXXXX.co.uk"
strSMTPTo = "i_MALC@XXXXXXX.co.uk"
strSMTPRelay = "auth.smtp.1and1.co.uk"
strTextBody = "Backup done vbs"
strSubject = "VBS Script"
strAddAttachment "D:\Backup docs1\Zip.zip"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = 465
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
'oMessage.AddAttachment strADDAttachment
oMessage.Send
'Wscript.Echo "Email sent."
Const TIMEOUT = 10
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Popup "Email sent" , TIMEOUT
DIM fso
Set fso=CreateObject("Scripting.FilesystemObject")
On Error Resume Next
fso.CopyFile "D:\Backup docs1\Zip.zip"
'Wscript.Echo "File copy complete."
strSMTPFrom = "backups@XXXXXX.co.uk"
strSMTPTo = "i_MALC@XXXXXXX.co.uk"
strSMTPRelay = "auth.smtp.1and1.co.uk"
strTextBody = "Backup done vbs"
strSubject = "VBS Script"
strAddAttachment "D:\Backup docs1\Zip.zip"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sen...") = 2
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smt...") = 465
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
'oMessage.AddAttachment strADDAttachment
oMessage.Send
'Wscript.Echo "Email sent."
Const TIMEOUT = 10
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Popup "Email sent" , TIMEOUT
RE: Sending email attachment
oMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smt...") = 1
oMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sen...") ="mail@yourdomain.com"
oMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sen...") ="yourpassword"
RE: Sending email attachment
CODE