Author Topic: CLR and System.Net.Mail.MailAddress  (Read 117 times)

seckner

  • Jr. Member
  • **
  • Posts: 68
CLR and System.Net.Mail.MailAddress
« on: January 14, 2019, 10:09:39 am »
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

  • Tech Support
  • *****
  • Posts: 2814
    • WinBatch
Re: CLR and System.Net.Mail.MailAddress
« Reply #1 on: January 14, 2019, 10:44:34 am »
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
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

  • Jr. Member
  • **
  • Posts: 68
Re: CLR and System.Net.Mail.MailAddress
« Reply #2 on: January 14, 2019, 11:50:43 am »
Thank you so much!

td

  • Tech Support
  • *****
  • Posts: 2814
    • WinBatch
Re: CLR and System.Net.Mail.MailAddress
« Reply #3 on: January 14, 2019, 02:14:39 pm »
You were almost there already.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade