Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using email components

Status
Not open for further replies.

Ken011

MIS
Oct 13, 2006
66
US
Dear all,

I tried using the following code to send email.

First, I was getting "unable to relay" message.

Then I granted access to localhost (127.0.0.1).

Now, I no longer get the error but I don't receive any emails.

What am I doing wrong?

Please see my entire code.

THanks in advance.

Code:
    Sub sendRequest()
        'create the mail message
        Dim mail As New MailMessage()

        'set the addresses
        'to specify a friendly 'from' name, we use a different ctor
        mail.From = New MailAddress("helpdesk@work.com", "Help Desk")

        'since the To,Cc, and Bcc accept addresses, we can use the same technique as the From address
        'since the To, Cc, and Bcc properties are collections, to add multiple addreses, we simply call .Add(...) multple times
        mail.To.Add("john.doe@yahoo.com")
        'set the content
        mail.Subject = "This is an email"
        mail.Body = "this is the body content of the email."

        'send the message
        Dim smtp As New SmtpClient("127.0.0.1")
        smtp.Send(mail)
    End Sub 'sendRequest

I invoked it by simply putting

sendRequest() in sendButton() event handler.
 
This is unlikely to be an ASP.NET issue and more likely to be a problem with your SMTP server. I'd check in one of the windows forums to see if there is anything that is set up incorrectly.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
if the code is running in your local system also check if any eml files are there in the mailroot folder. That could also give you an inkiling...

Known is handfull, Unknown is worldfull
 
i discovered that the problem was I need to use our exchange server address.

As soon as I changed that, it started working.

But I do have another question, how do I format the body so that I could bold whatever part of the text I wanted to?

Here is the entire working:

Code:
    Protected Sub btnSendBillingEmail_Click()
        '//SqlCommand myCommand=new SqlCommand("Select Email from Student where  

        Dim objSmtpClient As SmtpClient = New SmtpClient("dddrr333", 25)

        Dim objSender As MailAddress = New MailAddress("john.doe@domain", "John Doe")

        Dim objReciever As MailAddress = New MailAddress("jane.doe@domain", "Jane Doe")

        Dim objMail As MailMessage = New MailMessage("john.doe@domain", "jane.doe@domain")
        objMail.Subject = "User Request"
        objMail.Body = "User Access Request form " & vbCrLf & vbCrLf & " " + DateTime.Now + " feedback was sent from an ASP.NET " & _
               "Web page.  Below you will find the feedback message " & _
               "send by " & Name.Text & "." & vbCrLf & vbCrLf & _
               "---------------------------------------" & vbCrLf & vbCrLf & _
               Notes.Text & vbCrLf

        objSmtpClient.Send(objMail)


    End Sub
 
have a look at how to send HTML emails in ASP.NET. its pretty simple...

Known is handfull, Unknown is worldfull
 
vbkris,

did you even read my post?

I said my email code was working. I just needed help with formatting.

For instance, how to make an item bold, italics, etc.

But never mind, I figured all that out.

Thanks for trying anyway.
 
>>did you even read my post?
yes i did! did you read mine?

>>I just needed help with formatting.
To do that you have to use HTML formatting in emails!

>>But never mind, I figured all that out.
And how did you manage to do it without HTML emails???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top