Get IP or Mac Address from email Sender (1 Viewer)

Moore71

DEVELOPER
Local time
Today, 11:12
Joined
Jul 14, 2012
Messages
158
Hi,
I have an access form form for sending emails within ms Access Application.
My problem now, Is there any way I can get the Mac Address from the very system used in sending and forward same to the email recipient secretly?

Any suggestion is welcome
Thanks for your quick response
 

sneuberg

AWF VIP
Local time
Today, 03:12
Joined
Oct 17, 2014
Messages
3,506
Maybe you could use the Shell function to run ipconfig /all and parse the MAC address out of the result.

Would you share with us what you want to do with it?
 

sneuberg

AWF VIP
Local time
Today, 03:12
Joined
Oct 17, 2014
Messages
3,506
@jdraw

Thanks for pointing us to the post. I've haven't been able to get the GetMac function to produce a MAC address on my Windows 7 system but I'm getting info from the CIMV2 class Ok. I don't need that so I just wanted to say that as can be seen here the CIMV2 class could be useful for a lot of things.
 

isladogs

MVP / VIP
Local time
Today, 11:12
Joined
Jan 14, 2017
Messages
18,219

Moore71

DEVELOPER
Local time
Today, 11:12
Joined
Jul 14, 2012
Messages
158
Thank you all for the quick and resourceful info.
But my puzzle now is how do I include the Mac address on my email form so that when a mail is sent, it will copy the Mac address of the current machine and send at the same time.
Here's my email sending code:
Private Sub cmdSend_Click()
On Error Resume Next

Dim oApp As Object
Dim oEmail As Object
Dim FSO As New FileSystemObject
Dim FolderPath As String
Dim FileName As String


Set oApp = CreateObject("Outlook.Application")
Set oEmail = oApp.CreateItem(0)

oEmail.To = Nz(Me.txtTo.Value, "")
oEmail.Subject = Nz(Me.txtSubjet.Value, "")
oEmail.Body = Nz(Me.txtBody.Value, "")

If FSO.FileExists(Nz(Me.txtAttachment.Value, "")) Then
FolderPath = CurrentProject.Path & "\Attachments"
If Not FSO.FolderExists(FolderPath) Then
FSO.CreateFolder FolderPath
End If
FSO.CopyFile Me.txtAttachment.Value, FolderPath & "", True
FileName = FSO.GetFileName(Me.txtAttachment.Value)

oEmail.Attachments.Add FolderPath & "" & FileName
End If

' If Len(Me.txtAttachment) > 0 Then
' oEmail.Attachments.Add Me.txtAttachment.Value
' End If

With oEmail
If Not IsNull(.To) And Not IsNull(.Subject) And Not IsNull(.Body) Then
.Send

Logging.WriteLog "Email Sent=To: " & Nz(Me.txtTo, "") _
& " Subject: " & Nz(Me.txtSubjet, "") _
& " Body: " & Nz(Me.txtBody, "") _
& " Attachment: " & Nz(Me.txtAttachment, "")

MsgBox "Email Sent!"
Else
MsgBox "Please Fill Out the Required Fields"
End If
End With

End Sub
Please help me to include the GetMacAddress() on where it's appropriate in this code above.
Regards,

Moore71
 

isladogs

MVP / VIP
Local time
Today, 11:12
Joined
Jan 14, 2017
Messages
18,219
It depends whether you want it to go in the subject line or the message body.

Choose ONE of these:

Code:
oEmail.Subject = Nz(Me.txtSubjet.Value, "") & " MAC Address: " & GetMacAddress()

OR

Code:
oEmail.Body = Nz(Me.txtBody.Value, "") & " MAC Address: " & GetMacAddress()

assuming you use the GetMacAddress function I referenced - otherwise GetMac()
 

sneuberg

AWF VIP
Local time
Today, 03:12
Joined
Oct 17, 2014
Messages
3,506
I think Colin meant:

Code:
oEmail.Subject = Nz(Me.txtSubjet.Value, "") & " MAC Address: " & Get[COLOR="red"]My[/COLOR]MACAddresss()

OR

Code:
oEmail.Body = Nz(Me.txtBody.Value, "") & " MAC Address: " & Get[COLOR="red"]My[/COLOR]MACAddresss()

if you are using the following function:

Code:
Function GetMyMACAddress() As String

    'Declaring the necessary variables.
    Dim strComputer     As String
    Dim objWMIService   As Object
    Dim colItems        As Object
    Dim objItem         As Object
    Dim myMACAddress    As String
    
    'Set the computer.
    strComputer = "."
    
    'The root\cimv2 namespace is used to access the Win32_NetworkAdapterConfiguration class.
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    
    'A select query is used to get a collection of network adapters that have the property IPEnabled equal to true.
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
    
    'Loop through all the collection of adapters and return the MAC address of the first adapter that has a non-empty IP.
    For Each objItem In colItems
        If Not IsNull(objItem.IPAddress) Then myMACAddress = objItem.MACAddress
        Exit For
    Next
    
    'Return the IP string.
    GetMyMACAddress = myMACAddress

End Function
 

isladogs

MVP / VIP
Local time
Today, 11:12
Joined
Jan 14, 2017
Messages
18,219
Oops. Thanks Steve for spotting my error.

Helps if I read my own post before re-posting!
 

Moore71

DEVELOPER
Local time
Today, 11:12
Joined
Jul 14, 2012
Messages
158
Thanks for the help.
But how I really want it is to automatically add the Mac Address without the knowledge of the sender.
So is there anyway the Mac address can be hidden such that the receiver only need to see the source Mac address

Thanks, once again
 

jdraw

Super Moderator
Staff member
Local time
Today, 06:12
Joined
Jan 23, 2006
Messages
15,379
Just curious-- can you tell us why you want this --other than an academic interest?
 

Moore71

DEVELOPER
Local time
Today, 11:12
Joined
Jul 14, 2012
Messages
158
I have an email solution, where I want anytime emails are forwarded to me, I should get the Mac Address of the local machine for my personal consumption
 

sneuberg

AWF VIP
Local time
Today, 03:12
Joined
Oct 17, 2014
Messages
3,506
Thanks for the help.
But how I really want it is to automatically add the Mac Address without the knowledge of the sender.
So is there anyway the Mac address can be hidden such that the receiver only need to see the source Mac address

Thanks, once again
Colin's suggestion concatenates the MAX address to the oEmail object; not into the form field. Why and how do you think the sender would see it this way?
 

sneuberg

AWF VIP
Local time
Today, 03:12
Joined
Oct 17, 2014
Messages
3,506
I have an email solution, where I want anytime emails are forwarded to me, I should get the Mac Address of the local machine for my personal consumption
How do you consume a MAC address?
 

isladogs

MVP / VIP
Local time
Today, 11:12
Joined
Jan 14, 2017
Messages
18,219
A serious response this time.

I am slightly bothered by the idea of what you are asking to do and I very much doubt those emailing you would be happy if they knew about it.

However as Steve has already said, my suggestion would do what you want.
Another way is to create an additional email which would be sent 'silently' by the Access database without opening Outlook and without leaving a record in the users' email folder.

This is easy enough to do if you send email using CDO

I do this for other purposes with my clients.
For example to send me an automated email when:
- program errors occur
- the client updates the location of BE files (as I need to include that in program updates)
etc
 

Users who are viewing this thread

Top Bottom