Solved  - Property to is read-only

Posted on 2007-08-02
Last Modified: 2012-05-05
I am sending an email using and for some strange reason I am being told that the 'To' property is read  only! Can anyone tell me why this is occurring???

Exception Details: System.MissingMemberException: Property 'To' is ReadOnly.

Imports System.Net
Imports System.Net.Mail

        Dim message = New MailMessage()
        message.To = New MailAddress("")
        message.From = ""
        message.Subject = Request.Form("SubjectTextBox")
        message.Body = Request.Form("ContentTextBox")
        Dim smtp = New SmtpClient()
            ErrorMessage.Text = "Your E-mail has been sent - Thank You"
        Catch ex As Exception
            Response.Write("Send failure: " + ex.ToString())
        End Try
Question by:clearchannel
    LVL 38

    Accepted Solution

    I think you need to use

    Message.To.Add(New MailAddress(""))
    LVL 38

    Expert Comment

    It's a collection rather than a singular object.
    LVL 16

    Expert Comment

    You can set the To address(es) in the constructor of MailMessage()

    Dim message = New MailMessage(sFromEmail, sToEmail)

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now