CLR and System.Net.Mail.MailAddress

Started by seckner, January 14, 2019, 10:09:39 AM

Previous topic - Next topic

seckner

Please be patient, I'm brand new to trying to understand both .NET and CLR. I found the code in the database for sending SMTP mail using .NET and it's been running for me for a while very successfully. Of course, now we need to modify it by sending TO more than one person. It will currently only send to a single email address, even if more than one address is listed.

MailAddress_From = ObjectClrNew( "System.Net.Mail.MailAddress", "FromA@email.com" )  will work
MailAddress_From = ObjectClrNew( "System.Net.Mail.MailAddress", "FromA@email.com, FromB@email.com" )  will work BUT only "FromB" will actually be sent

Searching on StackOverflow I've found both the   .To.Add   and  .Collection  commands but when I try to use either I always get an error  1848: CLR: Type name not found. Could I get some help in figuring out how to add the second To address?

Thanks for any help!


td

The "To" property of the "MailMessage" object returns a collection so to add an additional "to" address you need to call the collection's "Add" method:

Code (winbatch) Select
MailMessage = ObjectClrNew( 'System.Net.Mail.MailMessage', MailAddress_From, MailAddress_To )
MailAddress_To2 = ObjectClrNew( 'System.Net.Mail.MailAddress', 'guesswho@winbatch.com' )
MailMessage.To.Add(MailAddress_To2)


"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

seckner


td

"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade