Sending e-mail to a distribution group in asp.net

B

Brian Hanson

Hi,

I have an asp.net (vb) app where I am creating a Crystal Report,
exporting it to a .pdf file and then e-mailing that report, as an
attachment, to several users using System.Web.Mail.MailMessage(). One
of the properties is MailMessage.To which is my recipient list. All
is working well.

However, when I substitute individual email addresses in the
MailMessage.To string with the name of a distribution group, it fails
never giving an error.

Has anyone run across this before?

Thanks,
Brian
 
S

Steven Cheng[MSFT]

Hi Brian,


Thanks for posting in the community!
From your description, you used the "System.Web.Mail.MailMessage" buildin
components to send mail. This works well when you set the MailMessage's
"To" address as individual address( the (e-mail address removed) format?). However, you
found it didn't work if you use some certain distribute group's name as the
address to send the mail ,yes?
If there is anything I misunderstood, please feel free to let me know.

As for this problem, is the "group name" string you mentioned just the
certain group's alias? For example a certain newgroup or some other groups
such as Yahoo group?
If so, I think the alias (a friendly name) didn't work because each email
be sent need a specifyed "To" address, which need to be a valid address
which is formated as "(e-mail address removed)". The alias for friendly name is just used
to help user to remember it. And the mapping between the alias and their
actual address are usually done by some Mail client tools such as outlook
or some other web access tools.
So we need to specify the actual name of the group to the "To" member of
the MailMessage if we want to send a mail to that group.
And here is a FAQ list on the "System.Web.Mail" components,
#System.Web.Mail FAQ
http://systemwebmail.com/faq.aspx

There are detailed description on how to define friendly name(alias) for
MailMessage's "From" or "To" field:
#2.4 How do I change the FROM address to a friendly name?
http://systemwebmail.com/faq/2.4.aspx

#2.5 How do I change the TO address to a friendly name?
http://systemwebmail.com/faq/2.5.aspx

Please check out the above items. If you have anything unclear, please feel
free to post here.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
B

Brian Hanson

Hi Steven,

Thank you for your reply and I apologize for being vague. The group
name I was refering to was indeed an Outlook mail group or distribution
list.

In my app, this works and both Bill and Joe get the message.

MailMessage.To = “[email protected]; (e-mail address removed)”


However, my recipient list is not static and instead I would like to
send to an Outlook mail group.

For example, I have a group called TestGroup that has an SMTP address of
[email protected]” And TestGroup has 2 members; (e-mail address removed) and
(e-mail address removed) .

I am trying to get this to work:

MailMessage.To = “[email protected]


I am trying to avoid maintaining email addresses in an asp.net
application especially since they are already maintained in mail groups
in Outlook.


Thanks again,
Brian
 
S

Steven Cheng[MSFT]

Hi Brian,


Thanks for your followup. Based on your further reply, you're able to send
the mail using the detailed reciever list such as
"(e-mail address removed);[email protected];[email protected]..." but not able to via their group's
smtp address?
I've also done a test on my side. I send the mail via the following code

System.Web.Mail.MailMessage msg = new System.Web.Mail.MailMessage();
msg.From= "myemailaddress";
msg.To = txtSmtpAddress.Text;
msg.Subject = "Hello, just a test.";
msg.Body = "Sorry for disturbing you!";
System.Web.Mail.SmtpMail.SmtpServer = "smarthost";
System.Web.Mail.SmtpMail.Send( msg );

I used a local group in our Active Dirctory for test. It seems that this
works well, I'm able to send to the group via it's smtpaddress.

In addition, have you tryied send to any other groups? Does this problem
occurs every group you send?
I think you can also try using OutLook to do the same test to see whether
the same problem remains. I think there must be something else which cause
the problem. Please check out it and let know if you got any progress.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
B

Brian Hanson

Hi,

Thanks for working on this and you were right, it was something else on
my end.

My company is in the process of changing domain names, and the group I
set up to test with only used the new domain name. Somewhere in some
remote Exchange Server, it was adding an additional address with the old
domain name in an effort not to route the thing around the country to
send an email four desks away. All along though, though, I was able to
successfully send to this group new group via Outlook and even AOL, so I
thought the group was fine. Next, I used a generic dumping account as
my from address and never saw the undeliverable message that said it was
looking for the old domain address as well as the new. It was not until
I put my address in the from address that I saw the error.


Thanks again and sorry to send you on a goose chase.

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top