sending email via vb?

  • Thread starter Thread starter Howard
  • Start date Start date
H

Howard

I got this code to send email from a small vb program from
http://systemwebmail.com/faq/2.1.aspx

Dim mail As New MailMessage()
mail.To = "(e-mail address removed)"
mail.From = "(e-mail address removed)"
mail.Subject = "this is a test email."
mail.Body = "this is my test email body"
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

Dead simple and works fine behind a button in visual basic 2005.

However, I want to deploy a program based on this in a school where everyone
has their own laptop with internal email running of exchange server.
The program will allow an 'emergency' button on their desktop to send an
email to reception asking for assistance.

Qn. I have to hard code my own email address in the 'From' line to make it
work from my laptop.
How can I find out the email address of a particular user so that when the
program runs on their laptop, under their login, the 'from' field can be
filled in automatically so that the email comes from the right person?

Howard
 
How can I find out the email address of a particular user so that when the
program runs on their laptop, under their login, the 'from' field can be
filled in automatically so that the email comes from the right person?

You could grab it from the environment variables.

sUser = System.Environment.GetEnvironmentVariable("username")

Hope that helps,

J Wolfgang Goerlich
 
Howard said:
No, that just gives me their logon name, not their email address

Right. If the users' email addresses vary from (e-mail address removed),
then you will need a bit more code. You could pull it from Active
Directory, for example. Are you using AD? Also, what is your email
system? Exchange?

J Wolfgang Goerlich
 
its exchange.
However I've thought of an easier way - I'll just ask them the first time
the y=run the program and store it in a file

Howard
PS
You may be able to help with my other post - setting the TO field of a mail
message?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top