How to bind email from database to .vb file

Last post 04-25-2008 1:33 PM by Self Taught. 1 replies.

Sort Posts:

  • How to bind email from database to .vb file

    04-25-2008, 12:12 PM
    • Loading...
    • bluewire
    • Joined on 05-21-2007, 7:11 PM
    • Posts 15

    Hi, i use  vb to send email from a contact form.

    I use a detailsview to show information from a database. Also in the detailsview i have a contact form, in which, (in the vb file) i want to change the email adress.

    Normally it whould be smth like this: 

     Dim sb As New System.Text.StringBuilder
            Dim mMsg As String


            mTo = "info@mysite.com"
            mFrom = "info@mysite.com"
            mSubject = "from my contact form"

     

    Now, the problem is that i want to bind the email adress from a database. 

    like: Text='<%# Bind("email") %>'> 

    How can i do that? 

  • Re: How to bind email from database to .vb file

    04-25-2008, 1:33 PM
    Answer

    There are 2 ways to do what you want. First, is to do it like you have using either Value or Text depending on what you are doing....like this in the HTML:

    <%# DataBinder.Eval(Container.DataItem, "EmailAddress") %> EmailAddress is the column name from the sql code select statement.

    OR

    You could get the data directly from a database call and then populate the stringbuilder with it:

    sSQL = "SELECT EmailAddress FROM TableName WHERE something = something

    Then when you get the data back you can put it into a variable.

    SELECT * FROM Users WHERE Clue IS NOT NULL;

    >> 0 rows returned
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter