tags:

views:

354

answers:

6

My aspx page is hosted by Discountasp.net. I can use System.Net.Mail.MailMessage to send an email but it seems it must be TO my Discountasp.net acct. (They let you set email accts for your site.)

I want a form that does a calc and sends the info directly to the user who has typed in their email addr.

A: 

I don't think that they would limit you to sending mail out only to your discountasp.net account. I would imagine that you might be doing something wrong before I would imagine this is a limitation to discountasp.net.

If it does turn out to be a limitation, you should get on the horn with customer service there and have them either clear up the confusion for you.

TheTXI
+1  A: 

First, you need to check with your ISP what smtp settings they use (and potentially how many emails you get to send before being blacklisted as spammer, depending on what you're going to use this for...)

Secondly, when you have the correct setting in web.config, you should be able to send to anyone.


EDIT, in response to comment:

To be able to use System.Net.Mail properly, you should add the smtp settings (which you need to get from the ISP/Hosting service) to web.config as follows:

<configuration>
    <system.net>
        <mailSettings>
            <smtp from="[email protected]">
                <network host="smtpserver1" port="25" userName="username"
                                   password="secret" defaultCredentials="true" />
            </smtp>
        </mailSettings>
    </system.net>
</configuration>

See this tutorial for more information.

Tomas Lycken
That might be the problem. What must be in the web.config file? I didnt even copy it to the host because I needed no login/membership
A: 

Using System.Net.Mail.MailMessage you should be able to set any SMTP address you want.

 Dim message As New MailMessage("[email protected]", "[email protected]")
 message.Subject = "MessageSubject"
 message.Body = "MessageBody"

 Dim client As New SmtpClient(*EmailServerAddress*)
 client.Send(message)
SchwartzE
That's like what i'm doing, but I get an exception "Not a valid user at this location" unless my discountasp.net user is used as the 2nd param in your top line of code.
+4  A: 

Here is a link to the DiscountASP.NET "How to send email in ASP.NET 2.0" FAQ: https://support.discountasp.net/KB/a364/how-to-send-email-in-aspnet-20.aspx . It looks like you use "localhost" as your SMTP server, try the demo and see if it works for you. Good luck!

Zachary
that was it. i was using smtp.myspecificdomain.com but localhost was what worked. I added a line that set DefaultNetworkCredentials I saw on the msdn example, but i don't know if that was necessary or not.
A: 
dim mailObj as new MailMessage

mailObj.From = {from address}

mailObj.To = {to address}

mailObj.Subject = {subject}

mailObj.BodyFormat = MailFormat.Html

mailObj.Body = {body of message}

SmtpMail.SmtpServer = {mailserver name or IP}

SmtpMail.Send(mailObj)
RichO
A: 

Refer link below to know how to send mail using Gmail account in asp.net

Sending email using Gmail account in ASP.NET