473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

sending email via vb?

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
4 1340
> 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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
0
by: praba kar | last post by:
Dear All, I have doubt regarding mail sending smtplib module. The below code is I used to send a mail. ########################################## import email.Message import email.Utils...
3
by: VB Programmer | last post by:
I have an ASPX page where I send out emails through my mail server mail.MyDomain.com. When I send emails to MyName@MyDomain.com it sends PERFECTLY. When I try sending an email to any other address...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
2
by: =?Utf-8?B?QWRl?= | last post by:
HI All, I am encountering the following error when I try to send an email through a SMTP server. I believe the problem lies with the authentication part when the network crednetials are used,...
9
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient...
7
by: bleachie | last post by:
Hey, I just need some help, my form seems to not send me all of the 'guestNames' and 'guestEmails' forms. i use this function to add more guestnames and guestemail fields based on the number of...
10
by: Markgoldin | last post by:
I am sending an XML data from not dontnet process to a .Net via socket listener. Here is a data sample: <VFPData> <serverdata> <coderun>updateFloor</coderun> <area>MD2</area>...
31
by: happyse27 | last post by:
Hi All, I am trying for weeks how to send email from windows pc, which from my gmail account to my hotmail account. Using net::smtp module sending email failed,Kindly assist. (for the item d it...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.