Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 14, 2009 08:58 AM by noami
Aug 14, 2009 06:26 AM|LINK
I have read some codes posted at the forum regarding the topic of Send Email thru asp.net.
I have gone thru your code and modified it as below:
'here i defined my hotmail as recepient, so senders will send all their enquiries to my hotmail
<add key="MailToAddress" value="email@example.com"/>
<network host="smtp.gmail.com" port="587" userName="firstname.lastname@example.org" password="xx" defaultCredentials="false"/>
In code behind ( on button click):
Dim MailFrom As String = txtEmailAddress.Text.Trim
'receiver's email address
Dim MailTo As String = ConfigurationManager.AppSettings("MailToAddress")
Dim MailSubject As String = txtSubject.Text.Trim
Dim MailBody As String = txtBody.Text.Trim
If MailFrom <> "" And MailTo <> "" And MailBody <> "" Then
Dim MailClient = New SmtpClient
MailClient.EnableSsl = True
MailClient.Send(MailFrom, MailTo, MailSubject, MailBody)
PnlEmailForm.Visible = False
PnlEmailSentForm.Visible = True
lblMessage.Text = "Your email has been successfully sent to the Store Owner."
Catch SmtpExc As SmtpException
lblMessage.Text = SmtpExc.Message
Catch ex As Exception
lblMessage.Text = ex.Message
I have changed my default smtp virtual server, Access --> Relay-->IP address to "127.0.0.1" as well.
I have used this code in my shopping cart project - contact us Form. It's working fine but i have noticed a minor problem. In my hotmail inbox, it's always show the email's From address to my gmail address. I'm wondering how do i show the email's address and
name entered by the sender at my hotmail From address.
Hope someone can help me solve the problem. Thanks in advanced.
Aug 14, 2009 07:36 AM|LINK
Well you are suing google smtp, so you would obviously get the mail from same google account.
What you can do is, add the Customer or user name as part of subject or the subject to know who sent this mail, if you want to do it through gmail.
Now sending mail to users involves usage or your own server's smtp, the username being email@example.com or anything like that.
Aug 14, 2009 08:58 AM|LINK
Thanks for the info. I will test it.