Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 26th, 2008, 12:44 AM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default ASP VB.Net send email

Hey There,

I am having trouble wrapping my head arround sending emails in asp .net (VB).

I have updated my web.config with smtp settings, however when I do a page load event to create a new mailmessage class i get an error that MailMessage()is not defined.

Below is my web.config except and my page load event.

Thanks for your help on this, and I really hope someone can help.

-Rick

~~~Page Load~~~
Partial Class _500
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim msg As New MailMessage()

    End Sub
End Class

~~~Web Config ~~~
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network
            defaultCredentials="false"
             host="my.mail.server.com"
             port="25"
             userName="XXXX"
             password="XXXX" />
      </smtp>
    </mailSettings>
  </system.net>

(I replace the host / username / password with valid details.)

 
Old August 26th, 2008, 04:13 AM
Authorized User
 
Join Date: Apr 2008
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default

hi

i think you have to use System.Net.Mail.MailMessage while defining or else import System.Net.Mail and use MailMessage

Pon Saravanan
http://www.vbknowledgebase.com
 
Old August 26th, 2008, 12:08 PM
Registered User
 
Join Date: Aug 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ahhh, thanks

Is there a way todo this in the web.config file?

 
Old August 26th, 2008, 07:59 PM
Authorized User
 
Join Date: Apr 2008
Posts: 54
Thanks: 0
Thanked 4 Times in 4 Posts
Default

you can do it in pagelevel as follows, put the following line in top of the page.

imports System.Net.Mail

In web.config level
in web.config
<system.web>

    <pages>
        <imports>
            <add namespace="MyWeb.UI" />
        </imports>
    </pages>

</system.web>






Pon Saravanan
http://www.vbknowledgebase.com/WebAp...ridView-Paging





Similar Threads
Thread Thread Starter Forum Replies Last Post
send email by asp phuc2583 Classic ASP Basics 6 December 17th, 2007 10:52 PM
read/send email using WEBDEV and vb.net prashanthudupa.k Excel VBA 0 September 21st, 2006 06:39 AM
send MASS Emails in ASP.NET 2 with VB.NET 2005 alexdcosta ASP.NET 2.0 Basics 1 July 17th, 2006 12:31 AM
Smtp blocked, how can I send email use asp.net calvinpost ASP.NET 1.x and 2.0 Application Design 7 April 1st, 2004 09:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.