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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending mail by SMTP with no password

Status
Not open for further replies.

tg2003

IS-IT--Management
Feb 6, 2003
270
IL
Hi,

I'm trying to send a mail by SMTP client. It works for me, but the problem that I must specify a password of the sender.
How can I send it without specifying password? I think it should be possible.
Code:
Dim msg As New System.Net.Mail.MailMessage()
msg.To.Add("me@mycompany.com")
msg.From = New MailAddress("someone@mycompany.com", "Someone", System.Text.Encoding.UTF8)
msg.Subject = "subject"
msg.SubjectEncoding = System.Text.Encoding.UTF8
msg.BodyEncoding = System.Text.Encoding.UTF8
msg.Priority = MailPriority.High
msg.IsBodyHtml = True

Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(body, Nothing, "text/plain")

Dim client As New SmtpClient()
[b]client.Credentials = New System.Net.NetworkCredential("me@company.com", "mypassword")[/b]
client.Port = CInt(txtPort.Text)
client.Host = txtSMTPserver.Text
client.EnableSsl = False

client.Send(msg)

As I said - this code is works, but I try to avoid of specifying password ("NetworkCredential" line) .

Many thanks!
 

Here's how I do it:

'At the top of the code
Imports System.Web.Mail



Dim sm As New System.Web.Mail.MailMessage

SmtpMail.SmtpServer = "server.name.here"

sm.To = "someone@address.com"
sm.From = "me@myaddress.com"
sm.Subject = "Subject line here"
sm.Body = "Body of the message here"
sm.BodyFormat = MailFormat.Html

SmtpMail.Send(sm)



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top