jessiejane
Programmer
Hi,
I need to send an email to the distribution list when the file is not found.
When I checked with email server people - they said that they do not have particular server associated to the distribution list.
Here is the code. How would I change it to fit my needs
Any help is greatly appreciated.
sub sendemail()
Dim EmailTo As String 'Emailaddres for user to send
Dim EmailFrom As String 'Emailaddres for user from
Dim MailSubject As String 'Subject of Mail
Dim MessageBody As String 'Message
Dim ServerName As String 'Server Name - important
ServerName = "<<Your SMTP server's Name>>"
'Similarly, add in EmailTo, EmailFrom etc parameters here
EmailTo = "someone@recipient.net"
EmailFrom = "me@mysqlf.net"
...
.....
'Set the SMTP Server's address
SmtpMail.SmtpServer = ServerName
'This is the code that sends out the email based on whatever server information you've set
'Enclosed within Try-Catch block to catch exceptions in case of errors
Try
SmtpMail.Send (EmailFrom, EmailTo, MailSubject, MessageBody)
Catch ex As Exception
MsgBox ( "Delivery Failure: " & ex.Source & ex.Message )
End Try
end sub
I need to send an email to the distribution list when the file is not found.
When I checked with email server people - they said that they do not have particular server associated to the distribution list.
Here is the code. How would I change it to fit my needs
Any help is greatly appreciated.
sub sendemail()
Dim EmailTo As String 'Emailaddres for user to send
Dim EmailFrom As String 'Emailaddres for user from
Dim MailSubject As String 'Subject of Mail
Dim MessageBody As String 'Message
Dim ServerName As String 'Server Name - important
ServerName = "<<Your SMTP server's Name>>"
'Similarly, add in EmailTo, EmailFrom etc parameters here
EmailTo = "someone@recipient.net"
EmailFrom = "me@mysqlf.net"
...
.....
'Set the SMTP Server's address
SmtpMail.SmtpServer = ServerName
'This is the code that sends out the email based on whatever server information you've set
'Enclosed within Try-Catch block to catch exceptions in case of errors
Try
SmtpMail.Send (EmailFrom, EmailTo, MailSubject, MessageBody)
Catch ex As Exception
MsgBox ( "Delivery Failure: " & ex.Source & ex.Message )
End Try
end sub