Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email to distribution List

Status
Not open for further replies.

jessiejane

Programmer
Oct 29, 2009
32
0
0
US
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
 
The quick answer is you can't email to a distribution. While a distribution list might look similar no matter how it was create they can actually be different. There may be more types, but the two I can think of right off the top of my head are: The first is a name assigned to a collection of email addresses. The name means nothing to the mail protocol (smtp, imap, etc.). The mail server simply knows that if the sender sends to "All My Friends" that it needs to send that message to each email address on the "All My Friends" list. The second is actually an email forward so that any email sent to "All My Friends" actually goes to AllMyFriends@domain.com which is then forwarded to each eamil address associated with AllMyFriends@domain.com.

What does this mean to you is that first you need to know where the distribution list is saved and/or what type it is. If it is a forward then you can just email to AllMyFriends@domain.com and be done with it. If it is the other type then you would need to access the email list. For example if you use outlook and the list is saved server side you would have to either get the addresses through out look then send using system.net.mail or send the message through outlook. Which I can't help you with the outlook part. I've never figured out how to pull the distribution list and I don't send through outlook as it will throw up a prompt warning you that and outside program is trying to use it so I can't send that way and so never looked into it.

So yes it all comes down to I can't help, but don't you feel better that I explained to you why. :)

-I hate Microsoft!
-Forever and always forward.
-My kingdom for a edit button!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top