Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 347
  • Last Modified:

E-mail Mail.CC

HI, when i try to run my application i get "the parameter 'addresses' cannot be an empty string" I am pulling supervisor name and e-mail from a SQL database that inserts into a checkbox list. when selected it creates a label.

here is the code i am working with.


  Mail.Subject = "An Incedent has Been Reported"
            Mail.To.Add("user.text.com")
            Mail.CC = New MailAddress (lblcbsuper.Text)
            Mail.From = New MailAddress("user@test.com")
            Mail.Body =
            Mail.IsBodyHtml = True

Dim smtp As New SmtpClient("mail.precisionaerogroup.com")

            smtp.Send(Mail)





        Catch ex As Exception
            MsgBox(ex.Message)

        End Try

        Response.Redirect("Submitted.aspx")
0
pai_01
Asked:
pai_01
  • 3
  • 3
  • 2
2 Solutions
 
David L. HansenProgrammer AnalystCommented:
When you debug and step through does the error occur on the "Mail.CC = New MailAddress (lblcbsuper.Text)?"
0
 
pai_01Author Commented:
yes, it is also highlighted and says "Property 'CC' is read only
0
 
Molly FaganApplications Team SupervisorCommented:
Try using Mail.CC.Add(lblcbsuper.Text).  Unless you know you're always going to have a CC e-mail, I'd also do a check to make sure lblcbsuper.Text isn't an empty string before adding.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
pai_01Author Commented:
i tried that and it didn't work correctly. it said that it sent but it only sent to be and not to the CC from the checkbox list. also when i added the .add there is a red line under it that says

" Error      5      Overload resolution failed because no accessible 'Add' accepts this number of arguments.      c:\users\steveg\documents\visual studio 2010\Projects\Injury\Injury\Default.aspx.vb      152      13"
0
 
David L. HansenProgrammer AnalystCommented:
Do you have to use the CC, because you are allowed to add more than one person in the "To"

example:
Mail.To.Add("user.text.com")
Mail.To.Add(lblcbsuper.Text)
0
 
pai_01Author Commented:
that seemed to work. but instead of the lblcsuper. i used the slected value from the check box. thank you for all the help though and great ideas.
0
 
Molly FaganApplications Team SupervisorCommented:
Are you using System.Net.Mail?  If you are, is "Mail" in your code of type MailMessage?  An example from some code I have:

Dim oMsg = New MailMessage("fromaddress@email.com", "toaddress@email.com")

And then if I need to CC, I add those addresses in.
0
 
David L. HansenProgrammer AnalystCommented:
Glad to help.  Try mjfagan's suggestion, if it works we can split the points perhaps.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now