|
-
Jan 12th, 2008, 06:19 AM
#1
Thread Starter
Member
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
-
Jan 12th, 2008, 06:30 AM
#2
Frenzied Member
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]
-
Jan 12th, 2008, 06:49 AM
#3
Thread Starter
Member
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.
-
Jan 12th, 2008, 06:53 AM
#4
Frenzied Member
Last edited by toecutter; Jan 12th, 2008 at 07:22 AM.
-
Jan 12th, 2008, 07:10 AM
#5
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:
Try Dim reader As New IO.StreamReader("this file does not exist") Catch 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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|