Command Button that Sends Email with Username and Computer Name

padlocked17

Registered User.
Local time
Today, 14:02
Joined
Aug 29, 2007
Messages
276
I am looking to create a command button that will email both the username and computer name to a specified email address so that I can send a small database to each person and they can email me back with their username and computer name so there is no error and I can then input that information into the permissions for the database.

I've got code to reliably get the username and computername, I'm just not sure how to get that info sent.
 
Have you looked at SendObject in VBA?
 
Yeah, I just found that. Messing around with it now, so I'll probably create a report and send it that way.

Thanks!
 
airforcedad is always happy to help airforceruss. :p

I wouldn't even bother with a report. You could put both those values into a string and put the string into the body argument of SendObject.
 
Haha, airforceruss is always glad for airforcedad's help!

I'l mess around with the string. Right now I'm just collecting the information in an unbound form using text fields. I'm just seeing about moving that data that is collected to a nicely formatted email.
 
may is ask for the code of retreiving the username? i cannot seem to get it correct.
Like i mentioned in one of my threads, i DO have code to retreive the username, however on most pc's its retreived correctly but on some pc's the username is nog getting retreived and i get an error message......

I thought i figured it out by finding that in some cases Access has problems retreiving the username (with the environ(...) function and vba.environ(...) function, so i got a workaround for this, but this fails as well)...i am very much in need of a code that 'always' works.......

No i am not desperate :) but i do need a correct code for my db

Thanks for helping me out with this..
 
With environ("Username") are you using the text or are you using the Numerical value?

Also, are you going across Windows versions?
 
I am using the textvalue (in my case that would be for instance tjs01 as my username).

Windows versions are the same on every pc.
 
hi,

Thanks for both the api solutions...both work great on my pc...

But...

Code:
rivate Declare Function apiGetComputerName Lib "kernel32" Alias _
    "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Function fOSMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
    lngLen = 16
    strCompName = String$(lngLen, 0)
    lngX = apiGetComputerName(strCompName, lngLen)
    If lngX <> 0 Then
        fOSMachineName = Left$(strCompName, lngLen)
    Else
        fOSMachineName = ""
    End If
End Function

works on my workspace perfectly, but when logging in the novell network on another pc the error appears in
Code:
strCompName = String$(lngLen, 0)
on the String$.

Maybe i have something wrong in my follow up:
1) the above mentioned code is a module, in which fOSUsername = tjs01
2) the fOSUsername is always used in select, append or update queries (for instance: select .... from ... where tblX.session = fOSUsername)

Again: on my workspace it works fine, the fOSUsername is stored correctly into the tbl.X and also on one form (splashscreen) the fOSUsername is shown correctly, but on other pc's, the fOSUsername fails...

Please advise (again :) on hopefully more solutions...)
 

Users who are viewing this thread

Back
Top Bottom