473,215 Members | 1,271 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,215 software developers and data experts.

Send simple EMail

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
4 4225
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
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: David Burson | last post by:
Hi, I have a VB.NET windows app that needs to automatically send a simple text email when my users run a new version of the app for the first time. I thought this would be simple, but after...
0
by: Robert Smith | last post by:
Hello, I have created a simple asp web page to send an email with the send button event as attached. However when I click the send button nothing happens and I know the email address is correct. I...
1
by: StevenBarnes | last post by:
I need to have some .Net code be able to send Email using my ISP's SMTP server. I found some articles on how to use the MAIL FROM: and RCPT TO: commands that you can stream to a tcp connection on...
5
by: Le, Thanh-Nhan | last post by:
Hi, I want to send a simple mail with C#. I have tried the following, but they don't work: - some solutions on CodeProject websites. - shellExecute(mailto:xxx@yyy.com?subject=aaa&body=bbb). ...
4
by: blu3g85 | last post by:
how to use asp.net page to send an email? ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World!...
10
by: Mike Charney | last post by:
Is there a simple way to send SMTP email from Access VBA? Mike m charney at dunlap hospital dot org
0
by: Chicka | last post by:
I need/want to be able to send an email from a website running IIS and CDONTS for mail (or ASPMAIL) that comes into the inbox as an appointment to be accepted. The company is not running...
8
by: Shailja | last post by:
Hi, Kindly help me how to send simple EMail from my VB Software? I am stucked with this problem. What coding do i need to write? I want to do it without using SMTP Server. Kindly let me know if...
3
by: civettina | last post by:
Hi, I'm trying to send an email to' sample@sample.com' when a new row on my table contactform_con is inserted. Basically, when a person fills out the contact form (contactform_con) I want one...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.