Click here to Skip to main content
15,893,588 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionOnly refreshing the part of a page Pin
Imtiaz Murtaza15-Nov-06 1:10
Imtiaz Murtaza15-Nov-06 1:10 
AnswerRe: Only refreshing the part of a page Pin
l0kke15-Nov-06 4:19
l0kke15-Nov-06 4:19 
AnswerRe: Only refreshing the part of a page Pin
ednrgc15-Nov-06 4:53
ednrgc15-Nov-06 4:53 
QuestionFill form fields in microsoft word doc using asp.net Pin
vijeta_r15-Nov-06 1:07
vijeta_r15-Nov-06 1:07 
Questiondropdownlist overlaps the jscript menu Pin
Amit Kushwaha15-Nov-06 1:00
Amit Kushwaha15-Nov-06 1:00 
AnswerRe: dropdownlist overlaps the jscript menu Pin
RichardGrimmer15-Nov-06 1:12
RichardGrimmer15-Nov-06 1:12 
AnswerRe: dropdownlist overlaps the jscript menu Pin
Paddy Boyd15-Nov-06 1:17
Paddy Boyd15-Nov-06 1:17 
QuestionSending email with ASP.NET 2.0 Pin
shapper15-Nov-06 0:29
shapper15-Nov-06 0:29 
Hello,

I created an ASP.NET 2.0 custom control which includes various TextBoxes, Labels and a button.
Basically is a contact form. When the button is pressed the values are sent by email.

I want to use the mailSettings values in my Web.Config file.

Everything works fine if I use in my bSubmit function:

smtpClient.Host = "mail.domain.com"
smtpClient.Port = "25"
smtpClient.UseDefaultCredentials = False
smtpClient.Credentials = New Net.NetworkCredential("user@domain.com", "password")
smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network

But if I don't include this code I get the error:

System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such user here at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at MyNamespace.Web.UI.Form.Contact.bSubmit_Click(Object sender, EventArgs e)

Shouldn't it be using the Web.Config values?
And if yes, why am I getting an error if the values are the same:

<system.net>
<mailSettings>
<smtp deliveryMethod = "network">
<network
defaultCredentials = "true"
host = "mail.domain.com"
password = "password"
port = "25"
userName = "user@domain.com" />
</smtp>
</mailSettings>
</system.net>

My bSubmit_Click function, inside my custom control, is the following:

Private Sub bSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bSubmit.Click

' Create new mail message
Dim message As New System.Net.Mail.MailMessage

' Define mail message properties
With message

' Define various properties
.To.Add(New System.Net.Mail.MailAddress(Me.ToAddress, Me.ToName))
.Body = tbMessage.Text
.IsBodyHtml = True

' Define fromMailAddress
If Me.NameVisible Then
.From = New System.Net.Mail.MailAddress(tbEmail.Text, tbName.Text)
Else
.From = New System.Net.Mail.MailAddress(tbEmail.Text)
End If

' Define subject
If Me.SubjectVisible Then
.Subject = tbSubject.Text
End If

End With

' Define a new mail SMTP client
Dim smtpClient As New System.Net.Mail.SmtpClient

' Send the mail message and define sent property
Try

' Send the mail message
smtpClient.Send(message)

' Define sent property
Me.Sent = True

Catch ex As Exception

' Define sent property
Me.Sent = False

End Try

' Raise the OnFormSubmited event
RaiseEvent FormSubmited(Me, EventArgs.Empty)

End Sub

Thanks,
Miguel

QuestionGenerate GUID using 2 digit State Code Pin
AmitChampaneri15-Nov-06 0:16
AmitChampaneri15-Nov-06 0:16 
AnswerRe: Generate GUID using 2 digit State Code Pin
l0kke15-Nov-06 4:38
l0kke15-Nov-06 4:38 
GeneralRe: Generate GUID using 2 digit State Code Pin
Colin Angus Mackay15-Nov-06 5:41
Colin Angus Mackay15-Nov-06 5:41 
AnswerRe: Generate GUID using 2 digit State Code Pin
Colin Angus Mackay15-Nov-06 5:38
Colin Angus Mackay15-Nov-06 5:38 
Questionneed help Pin
Shriya Kapoor14-Nov-06 23:53
Shriya Kapoor14-Nov-06 23:53 
AnswerRe: need help Pin
Paddy Boyd15-Nov-06 0:23
Paddy Boyd15-Nov-06 0:23 
GeneralRe: need help Pin
Paddy Boyd15-Nov-06 0:38
Paddy Boyd15-Nov-06 0:38 
GeneralRe: need help Pin
Shriya Kapoor15-Nov-06 0:43
Shriya Kapoor15-Nov-06 0:43 
GeneralRe: need help Pin
Shriya Kapoor15-Nov-06 0:56
Shriya Kapoor15-Nov-06 0:56 
GeneralRe: need help Pin
l0kke15-Nov-06 6:13
l0kke15-Nov-06 6:13 
GeneralRe: need help Pin
Guy Harwood15-Nov-06 6:17
Guy Harwood15-Nov-06 6:17 
GeneralRe: need help Pin
l0kke17-Nov-06 0:57
l0kke17-Nov-06 0:57 
GeneralRe: need help Pin
Guy Harwood17-Nov-06 1:25
Guy Harwood17-Nov-06 1:25 
AnswerRe: need help Pin
Deepak the Cool15-Nov-06 0:47
Deepak the Cool15-Nov-06 0:47 
AnswerRe: need help Pin
PavanPareta15-Nov-06 1:01
PavanPareta15-Nov-06 1:01 
AnswerRe: need help Pin
Guffa15-Nov-06 1:24
Guffa15-Nov-06 1:24 
GeneralRe: need help Pin
Shriya Kapoor15-Nov-06 1:36
Shriya Kapoor15-Nov-06 1:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.