Results 1 to 5 of 5

Thread: sending mails

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    sending mails

    I try to use the following code to send mails but gives me the error :
    "A first chance exception of type 'System.Web.HttpException' occurred in System.Web.dll"

    Imports System
    Imports System.Web.Mail

    Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim oMsg As Web.Mail.MailMessage = New Web.Mail.MailMessage()
    oMsg.From = "[email protected]"
    oMsg.To = "[email protected]"
    oMsg.Subject = "Email with Attachment Demo"
    oMsg.Body = "This is the main body of the email"

    Try
    SmtpMail.SmtpServer = "pop.gmail.com"
    SmtpMail.Send(oMsg)
    Catch ehttp As System.Web.HttpException
    Console.WriteLine("0", ehttp.Message)
    Console.WriteLine("Here is the full error message")
    Console.Write("0", ehttp.ToString())
    End Try

    End Sub

  2. #2
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160

    Re: sending mails

    makko

    Have search in the office section, i know there is code in there for this.

    ps
    please use code tags

    [code]your code here[forward slashcode]

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2007
    Posts
    58

    Re: sending mails

    what ?

    Are you kiddin' me ? VB.NET send mail code in the OFFICE section ?

    If you just want to make posts I suggest to find another thread

    And for your information the code I posted above is taken from MSDN ... The code is ok ... I made the post thinking I made a bad setting or not entering all informations like username/password/SSL ... not searching in OFFICE section

    If you dont help please dont send me to search another sections ... I appreciate though you dont told me to search MSDN
    Last edited by makko; Jan 12th, 2008 at 06:52 AM.

  4. #4
    Frenzied Member toecutter's Avatar
    Join Date
    Apr 2006
    Location
    Brisbane, Australia
    Posts
    1,160
    Last edited by toecutter; Jan 12th, 2008 at 07:22 AM.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: sending mails

    Any code found in the Office Development forum will be specifically related to automating Office applications. For e-mail that basically means Outlook. This question has nothing whatsoever to do with Outlook.

    makko, you're trying to fix an issue that doesn't exist. You are not been "given an error". The debugger is simply telling you that an exception was thrown. Exceptions are allowed to be thrown. They are part of programming. Unless your app is crashing that exception is being caught and the necessary action taken to deal with it.

    For example, try putting this in your code:
    vb.net Code:
    1. Try
    2.     Dim reader As New IO.StreamReader("this file does not exist")
    3. Catch
    4. End Try
    and running it. The debugger will notify you of the first chance exception, i.e. that an exception was thrown, but it will continue on happily because the exception was caught. Now remove the Try...Catch block and run it again. The debugger will again notify you of the first chance exception, then your app will crash and the debugger will notify you of the unhandled exception. It's unhandled exceptions that you need to worry about.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width