My Assistant
![]()
Custom Search
|
![]() ![]() |
![]() |
![]() Post#1 | |
Posts: 530 Joined: 27-June 11 From: Temecula, California ![]() | This is the closest forum I could find for running powershell commands. Please let me know if this post is better placed elsewhere. I need to send an email which I am doing via powershell (below). Part of the coding is pulling the active users email from AD. My current issue is how to call from within in Microsoft Access. I'm found ways to run this if I wanted to save the script as a .PS or .tst file. But I'm looking to keep it all within access. **This code works in Powershell** CODE $searcher = [adsisearcher]"(samaccountname=$env:USERNAME)" $FromEmailAddress = $searcher.FindOne().Properties.mail $body = "Test 1" send-mailmessage -from $FromEmailAddress -to "David92595@domain.com" -subject "Testing" -body $body -smtpServer mail.domain.com Any idea's? Thank You! David92595 |
![]() Post#2 | |
Posts: 530 Joined: 27-June 11 From: Temecula, California ![]() | I've worked out the string. Still now sure how to call the powershell command and insert my variable correctly. CODE Public Function SendMailwShell() Dim Email As String Dim retval Email = "" & "$searcher = [adsisearcher]" & """" & "(samaccountname=$env:USERNAME)" & """" & "; $FromEmailAddress = $searcher.FindOne().Properties.mail; $body = """ & "Testing_1""" & "; send-mailmessage -from $FromEmailAddress -to """ & "david.katanski@mtglawfirm.com""" & " -subject " & """" & "Testing""" & " -body $body -smtpServer smtp" Debug.Print Email retval = Shell("powershell email") MsgBox retval End Function |
![]() Post#3 | |
![]() UtterAccess Moderator Posts: 11,870 Joined: 6-December 03 From: Telegraph Hill ![]() | Surely: CODE retval = Shell("powershell " & Email) ? d |
![]()
Custom Search
|
![]() | Search Top Lo-Fi | 7th December 2019 - 01:09 AM |