By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,928 Members | 1,810 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,928 IT Pros & Developers. It's quick & easy.

Send simple EMail

P: n/a
VS 2005 - XP media - VB .net - winforms - .net 2.0

Just trying to send an email, here is the code and the error message that I
get. I can't figure out how to fix it?

'create the mail message

Dim mail As New MailMessage()

Dim smtp As New SmtpClient("http://mail.Someplace.com")

Dim WhatTimeIsIt As DateTime

mail.From = New MailAddress("To**@Someplace.com")

mail.To.Add("To******@Someplace.com")

WhatTimeIsIt = DateTime.Now

mail.Subject = "This is an email" & Format(WhatTimeIsIt) & " - "
& " winforms"

mail.Body = "this is a sample body"

'This next line didn't help error but i was getting error prior to putting
this line in.

smtp.Credentials = New Net.NetworkCredential("Username", "Secrete")

smtp.Send(mail)

-----------------Error Message -----------------------

System.Net.Mail.SmtpException was unhandled

Message="Failure sending mail."

Source="System"

StackTrace:

at System.Net.Mail.SmtpClient.Send(MailMessage message)

at WinformsEMailtest.Form1.Button1_Click(Object sender, EventArgs e)
in C:\AllUserFiles\Movies\WinformsEMailtest\WinformsE Mailtest\Form1.vb:line
28

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)

at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)

at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)

at System.Windows.Forms.Application.Run(ApplicationCo ntext context)

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)

at WinformsEMailtest.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context( Object state)

at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

------------------------------------------------------------------------------------------------------------------------------------------------------
Jun 16 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Tom
You don't need HTTP:// in front of the SMTP server, it isn't http, so
you dont need it :)

Tony M wrote:
VS 2005 - XP media - VB .net - winforms - .net 2.0

Just trying to send an email, here is the code and the error message that I
get. I can't figure out how to fix it?

'create the mail message

Dim mail As New MailMessage()

Dim smtp As New SmtpClient("http://mail.Someplace.com")

Dim WhatTimeIsIt As DateTime

mail.From = New MailAddress("To**@Someplace.com")

mail.To.Add("To******@Someplace.com")

WhatTimeIsIt = DateTime.Now

mail.Subject = "This is an email" & Format(WhatTimeIsIt) & " - "
& " winforms"

mail.Body = "this is a sample body"

'This next line didn't help error but i was getting error prior to putting
this line in.

smtp.Credentials = New Net.NetworkCredential("Username", "Secrete")

smtp.Send(mail)

-----------------Error Message -----------------------

System.Net.Mail.SmtpException was unhandled

Message="Failure sending mail."

Source="System"

StackTrace:

at System.Net.Mail.SmtpClient.Send(MailMessage message)

at WinformsEMailtest.Form1.Button1_Click(Object sender, EventArgs e)
in C:\AllUserFiles\Movies\WinformsEMailtest\WinformsE Mailtest\Form1.vb:line
28

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)

at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)

at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)

at System.Windows.Forms.Application.Run(ApplicationCo ntext context)

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)

at WinformsEMailtest.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context( Object state)

at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

------------------------------------------------------------------------------------------------------------------------------------------------------

Jun 16 '07 #2

P: n/a
On Jun 15, 11:46 pm, "Tony M" <TonyMast_NOS...@msn.comwrote:
VS 2005 - XP media - VB .net - winforms - .net 2.0

Just trying to send an email, here is the code and the error message that I
get. I can't figure out how to fix it?

'create the mail message

Dim mail As New MailMessage()

Dim smtp As New SmtpClient("http://mail.Someplace.com")

Dim WhatTimeIsIt As DateTime

mail.From = New MailAddress("T...@Someplace.com")

mail.To.Add("TonyM...@Someplace.com")

WhatTimeIsIt = DateTime.Now

mail.Subject = "This is an email" & Format(WhatTimeIsIt) & " - "
& " winforms"

mail.Body = "this is a sample body"

'This next line didn't help error but i was getting error prior to putting
this line in.

smtp.Credentials = New Net.NetworkCredential("Username", "Secrete")

smtp.Send(mail)

-----------------Error Message -----------------------

System.Net.Mail.SmtpException was unhandled

Message="Failure sending mail."

Source="System"

StackTrace:

at System.Net.Mail.SmtpClient.Send(MailMessage message)

at WinformsEMailtest.Form1.Button1_Click(Object sender, EventArgs e)
in C:\AllUserFiles\Movies\WinformsEMailtest\WinformsE Mailtest\Form1.vb:line
28

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)

at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)

at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason,
ApplicationContext context)

at System.Windows.Forms.Application.Run(ApplicationCo ntext context)

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)

at WinformsEMailtest.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context( Object state)

at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

------------------------------------------------------------------------------------------------------------------------------------------------------
Also, Mcafee and other virus protection programs prevent
System.Net.Mail and System.Web.Mail from sending emails - it picks
them up as a mass mailing worm and generates the "Failure sending
mail" message. Be sure to add them to the list of allowed programs if
you think it will be a problem.

Thanks,

Seth Rowe

Jun 16 '07 #3

P: n/a

Ok, I kind of got it to work thanks to you guys.
I can send some emails successfully to 2 servers only (or websites).
Everything else gives me the error listed below and I know they are good
addresses.
I also used bo****@altohiway.com and same error (which is a place to test
email).
If I go to outlook (same computer same time) I can send to all these email
addresses without error.

"Mailbox unavailable. The server response was: <bo****@altohiway.comNo
such user here"}
System.Net.Mail.SmtpFailedRecipientException'

Thanks again in advance
"Tony M" <To*************@msn.comwrote in message
news:eJ**************@TK2MSFTNGP05.phx.gbl...
VS 2005 - XP media - VB .net - winforms - .net 2.0

Just trying to send an email, here is the code and the error message that
I get. I can't figure out how to fix it?

'create the mail message

Dim mail As New MailMessage()

Dim smtp As New SmtpClient("http://mail.Someplace.com")

Dim WhatTimeIsIt As DateTime

mail.From = New MailAddress("To**@Someplace.com")

mail.To.Add("To******@Someplace.com")

WhatTimeIsIt = DateTime.Now

mail.Subject = "This is an email" & Format(WhatTimeIsIt) & " - "
& " winforms"

mail.Body = "this is a sample body"

'This next line didn't help error but i was getting error prior to putting
this line in.

smtp.Credentials = New Net.NetworkCredential("Username", "Secrete")

smtp.Send(mail)

-----------------Error Message -----------------------

System.Net.Mail.SmtpException was unhandled

Message="Failure sending mail."

Source="System"

StackTrace:

at System.Net.Mail.SmtpClient.Send(MailMessage message)

at WinformsEMailtest.Form1.Button1_Click(Object sender, EventArgs e)
in
C:\AllUserFiles\Movies\WinformsEMailtest\WinformsE Mailtest\Form1.vb:line
28

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)

at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)

at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(ApplicationCo ntext context)

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)

at WinformsEMailtest.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context( Object state)

at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

------------------------------------------------------------------------------------------------------------------------------------------------------


Jun 17 '07 #4

P: n/a
Nevermind I figured it out.
Incorrect credentials!
Works fin now thanks again
"Tony M" <To*************@msn.comwrote in message
news:eJ**************@TK2MSFTNGP05.phx.gbl...
VS 2005 - XP media - VB .net - winforms - .net 2.0

Just trying to send an email, here is the code and the error message that
I get. I can't figure out how to fix it?

'create the mail message

Dim mail As New MailMessage()

Dim smtp As New SmtpClient("http://mail.Someplace.com")

Dim WhatTimeIsIt As DateTime

mail.From = New MailAddress("To**@Someplace.com")

mail.To.Add("To******@Someplace.com")

WhatTimeIsIt = DateTime.Now

mail.Subject = "This is an email" & Format(WhatTimeIsIt) & " - "
& " winforms"

mail.Body = "this is a sample body"

'This next line didn't help error but i was getting error prior to putting
this line in.

smtp.Credentials = New Net.NetworkCredential("Username", "Secrete")

smtp.Send(mail)

-----------------Error Message -----------------------

System.Net.Mail.SmtpException was unhandled

Message="Failure sending mail."

Source="System"

StackTrace:

at System.Net.Mail.SmtpClient.Send(MailMessage message)

at WinformsEMailtest.Form1.Button1_Click(Object sender, EventArgs e)
in
C:\AllUserFiles\Movies\WinformsEMailtest\WinformsE Mailtest\Form1.vb:line
28

at System.Windows.Forms.Control.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnClick(EventArgs e)

at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)

at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ButtonBase.WndProc(Message& m)

at System.Windows.Forms.Button.WndProc(Message& m)

at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)

at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)

at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)

at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)

at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason, ApplicationContext context)

at System.Windows.Forms.Application.Run(ApplicationCo ntext context)

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()

at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)

at WinformsEMailtest.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)

at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)

at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()

at System.Threading.ThreadHelper.ThreadStart_Context( Object state)

at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadHelper.ThreadStart()

------------------------------------------------------------------------------------------------------------------------------------------------------


Jun 17 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.