By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,234 Members | 1,908 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,234 IT Pros & Developers. It's quick & easy.

sending email via vb?

P: n/a
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 = "me@mycompany.com"
mail.From = "yo*@yourcompany.com"
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
Mar 23 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
> 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("usernam e")

Hope that helps,

J Wolfgang Goerlich

Mar 23 '06 #2

P: n/a
No, that just gives me their logon name, not their email address

Howard
<jw********@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
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("usernam e")

Hope that helps,

J Wolfgang Goerlich

Mar 24 '06 #3

P: n/a
Howard wrote:
No, that just gives me their logon name, not their email address


Right. If the users' email addresses vary from us******@yourdomain.com,
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

Mar 25 '06 #4

P: n/a
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?
<jw********@gmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
Howard wrote:
No, that just gives me their logon name, not their email address


Right. If the users' email addresses vary from us******@yourdomain.com,
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

Mar 25 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.