I need to send an automatic email with an attachment each day at a specified time. I also need the attachment to be grabbed from a location on my network each as it changes daily. Can I do this with exchange? I am also using outlook 2003 as well.
Try this as a VBS script and schedule it to run when you want it to.
Call the function with sSubject as the Email subject and sPathfile as the attachment that you want to send. To add more attachments, just add ".AddAttachment " again with the path to whatever file you want to add. You will have to do some extra work if the filename is constantly changing unless it a predictable pattern like a date.
Function MailScript(sSubject,sPathfile)
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strSmartHost
Dim strMessageBody
' apply the settings to the message
With iMsg
Set .Configuration = iConf
.To = "To address"
.From = "From Address"
.Subject = sSubject
.TextBody = "Body of Email"
.AddAttachment sPathFile
.Send
End With
' cleanup of variables
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
OK I have tried to get this working but I am not getting anything. I can execute the script with no errors, but I don't recieve an email to the test account.
Here is the script with my info. Am I doing this right? I don't have a lot of experience with VB script.
Function MailScript(sSubject,sPathfile)
Dim iMsg
Dim iConf
Dim Flds
Dim strHTML
Dim strSmartHost
Dim strMessageBody
' apply the settings to the message
With iMsg
Set .Configuration = iConf
.To = "pendarus@mindspring.com"
.From = "barneye@inductor.com"
.Subject = "test"
.TextBody = "test"
.AddAttachment "U:\Invsum\Parthunter\inductors_same_day.xls"
.Send
End With
' cleanup of variables
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
It looks like you got it up right. I always have the To: and From: with the same domain as the mail server. You might be blocked for SMTP relay. Setup Outlook Express with these settings and try and email back out. See if you get a bounced message for SMTP relay or for DNS reverse lookup.
I think there is a way to force login from the script. I will look into it and get back to you. Let me know how the OE test goes.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.