I am trying to send email which I have done before but now I am using a different server and now I am getting this error - here is my code.
Code Snippet
Dim Message As Mail.MailMessage = New Mail.MailMessage() Dim Smtp As New Mail.SmtpClient() Dim SmtpUser As New System.Net.NetworkCredential() '-- Build Message Message.From = New Mail.MailAddress("from@domain.com", "FromName") Message.To.Add(New Mail.MailAddress("to@gmail.com", "toName")) Message.IsBodyHtml = False Message.Subject = "Stuff" Message.Body = "More Stuff" '-- Define Authenticated User SmtpUser.UserName = "from@domain.com" SmtpUser.Password = "pass" SmtpUser.Domain = "smtp.1and1.com" '-- Send Message Smtp.UseDefaultCredentials = False Smtp.Credentials = SmtpUser Smtp.Host = "smtp.1and1.com" Smtp.DeliveryMethod = Mail.SmtpDeliveryMethod.Network Try Smtp.Send(Message) Catch ex As Exception TextBox1.Text = ex.ToString End Try This is the error I am getting - System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: must be authenticated at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at email_blaster.Form1.Form1_Load(Object sender, EventArgs e) in F:\email_blaster\email_blaster\Form1.vb:line 56 Any help on this would be greatly appreciated. |
| joeredmond2002 Sunday, September 23, 2007 3:49 AM |
Do you have the ability to make a test account on the server? One that you can post the information so it can be discussed?
Although sometimes it's not easy to find, almost every ISP posts the post and protocol information, otherwise people could not connect. You need to post that. I did not intend for you to execute the code I supplied because Gmail is really wierd. What I wanted you to see was credentials presentation, port and protocol information. I doubt your ISP uses SSL and that's what my method used, so it's no wonder it doesn't work.
So you need a test accountwhere you do notneed to protectthe account for security so we can test this.
|
| ReneeC Sunday, September 23, 2007 5:13 AM |
I responded to this and then thought better. Email_Blaster? |
| ReneeC Sunday, September 23, 2007 4:10 AM |
Thanks for the quick reply - but I tried that code and received the same error -
System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: must be authenticated at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at email_blaster.Form1.Form1_Load(Object sender, EventArgs e) in F:\email_blaster\email_blaster\Form1.vb:line 45
|
| joeredmond2002 Sunday, September 23, 2007 4:26 AM |
Do you have the ability to make a test account on the server? One that you can post the information so it can be discussed?
Although sometimes it's not easy to find, almost every ISP posts the post and protocol information, otherwise people could not connect. You need to post that. I did not intend for you to execute the code I supplied because Gmail is really wierd. What I wanted you to see was credentials presentation, port and protocol information. I doubt your ISP uses SSL and that's what my method used, so it's no wonder it doesn't work.
So you need a test accountwhere you do notneed to protectthe account for security so we can test this.
|
| ReneeC Sunday, September 23, 2007 5:13 AM |
I have an exchange server with 1an1, so I could set up a test acount - I did not use the ssl part in my test and I filled in the blanks with my info - I have connected to gmail before - but this one is giving me a headache - I will post the info of the test account soon.
|
| joeredmond2002 Sunday, September 23, 2007 6:14 AM |
Good,
Then post your code along with it and we can figure it out. Make sure you can connect with Outlook. I don't think Outlook express or Windows mail is compatible with exchange? |
| ReneeC Sunday, September 23, 2007 12:00 PM |
Sorry it took forever - I was receiving an error evertime I tried to reply to this thread - antways
user - e218218362@exchange.1and1.com pass - testertester
host - smtp.1and1.com
Thank you again
|
| joeredmond2002 Sunday, September 23, 2007 3:47 PM |
Here it is about 6 months, I no one seems to be able to post a answer to your question.
I am having the same problem, I tied you code and get the same "..authentication required..". I too, am using 1and1 or gmail or others.
QUESTION, Have you found the soution?
Thanks!
- Proposed As Answer bywolwil Wednesday, January 07, 2009 2:07 AM
-
|
| Rehabman Thursday, May 29, 2008 1:19 PM |
This is how I got it to work:
Imports Microsoft.VisualBasic
Imports System
Imports System.IO
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Net.Mail
Imports System.Net.Mime
Imports System.Collections.Generic
Imports System.Xml
Public Class Utility
Public Shared Sub SendMail(ByVal from As String, ByVal sTo As String, ByVal subject As String, ByVal body As String)
' Declare server name
Dim mailServerName As String = "smtp.1and1.com"
' MailMessage represents the e-mail being sent
Dim message As New Net.Mail.MailMessage(from, sTo, subject, body)
' set HTML body to true
message.IsBodyHtml = True
' set client information
Dim mailClient As New Net.Mail.SmtpClient()
mailClient.Host = mailServerName
' set Username and Password for SMTP Authentication
mailClient.Credentials = New Net.NetworkCredential("user@domain.com", "password")
' send email
mailClient.Send(message)
' dispose message
message.Dispose()
End Sub
End Class
---------------------------------------------------------------------------------
MyButton looks like this:
Protected Sub btnclick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim name As String = TextBox1.Text.Trim()
Dim comments As String = TextBox2.Text.Trim()
Dim sbMessage As New StringBuilder()
sbMessage.Append(name + " has submitted these comments on the contact us page. <br />")
sbMessage.Append( "Comments: " + comments)
sbMessage.Append( "<br /><br />This was sent on: " + DateTime.Now)
Utility.SendMail(" sender@domain.com", "reciever@domain.com", "subject", sbMessage.ToString())
Response.Redirect( "Home.aspx")
----------------------------------------------------------------------------
Hope this helps. BTW I used
- Proposed As Answer bywolwil Wednesday, January 07, 2009 2:16 AM
-
|
| wolwil Wednesday, January 07, 2009 2:10 AM |
What you are missing is this Smtp.EnableSsl = True, some EMails need this authentication.
|
| Forfe18 Wednesday, October 14, 2009 7:29 PM |