Note : Logged in User
Tested in Windows 10
Output Screenshots:
1. In the Endpoint Manager(EM), Click 'Ready to Review' -> 'Approve' -> 'Run'.
Select Devices and "Run as Logged in User" Option.
2. Once the Procedure Status is 'Started', a pop-up window for User Details will be displayed at Endpoint.
The Pop-up window will contain User Defined Instruction Message along with input entry fields for User Details(First Name, Last Name, National ID Number, Email Address)
3. If any of the above mentioned field is left blank and on clicking the 'Send' Button, a warning window will be dispalyed stating that the "blank field value cannot be empty"
In the above image, the "Last Name" field is left empty and 'Send' button is clicked, the Warning Window displayed stating "Last Name Cannot be Empty".
4. After entering all the fields in the Window, click 'Send' button, to mail the User Details to the Specific User or Administrator Email Address mentioned in the Procedure.
5. An email with User Details is received by the Specific email address. It Contains the details of the Endpoint Device Name, IP Address and User Details entered in the GUI in Endpoint.
NOTE : Email notification will be received and the Procedure will be exited ONLY when all the four fields in GUI are Entered.
6. Following is the image for EM Output
#To define a particular parameter, replace the 'parameterName' inside itsm.getParameter('parameterName') with that parameter's name
emailto=['XXX@XXX.com'] ## Provide an Toemail address where the mail need to be sent.You can also provide any number of To eamil address For example: ['tamil@yopmail.com','sensor@yopmail.com']
emailfrom='XXXX@gmail.com' ## Provide the From Email address from which the mail to be send
password='CCCCC' ##Provide password for from email
text = '''
Kindly enter your personal details here for a Validation\nKindly enter your personal details here for a Validation \nKindly enter your personal details here for a Validation\nKindly enter your personal details here for a Validation
'''##Please Enter the multiline text to be displayed in the Pop-up Window
smtpserver='smtp.gmail.com'
port=587
import Tkinter as tk
import tkMessageBox as mb
import os
import smtplib
import socket
import mimetypes
from email.mime.multipart import MIMEMultipart
from email import encoders
from email.message import Message
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
def computername():
return os.environ['COMPUTERNAME']
def ipaddress():
return socket.gethostbyname(socket.gethostname())
subject='%s %s User Details!!!!!'%(computername(), ipaddress())
def emailreport(subject, emailto,emailfrom,password,smtpserver,port,msgbody):
msg = MIMEMultipart()
msg["From"] = emailfrom
msg["To"] = ",".join(emailto)
msg["Subject"] = subject
msg.preamble = subject
body = MIMEText(msgbody)
msg.attach(body)
try:
server = smtplib.SMTP(smtpserver,port)
server.ehlo()
server.starttls()
server.login(emailfrom, password)
server.sendmail(emailfrom, emailto, msg.as_string())
server.quit()
return " \nThe email report has been sent to "+msg["To"]
except Exception as e:
return e
def validate_entry_fields():
fname=e1.get()
lname=e2.get()
id_no=e3.get()
email=e4.get()
if fname == '':
mb.showinfo(title="Warning!", message="First Name Cannot be empty")
if lname == '':
mb.showinfo(title="Warning!", message="Last Name Cannot be empty")
if id_no == '':
mb.showinfo(title="Warning!", message="Id Number Cannot be empty")
if email == '':
mb.showinfo(title="Warning!", message="Email Cannot be empty")
if ( fname and lname and id_no and email) != '':
print("First Name: %s\nLast Name: %s\nNational Identity Number: %s\nEmail Address: %s\n" %(fname, lname ,id_no ,email ))
msgbody=r'''Hi,
Please find the User Details below:
First Name: %s
Last Name: %s
National Identity Number: %s
Email Address: %s
Thank you.'''%(fname, lname ,id_no ,email )
print emailreport(subject,emailto,emailfrom,password,smtpserver,port,msgbody)
master.destroy()
master = tk.Tk()
master.geometry('650x400')
master.configure(background="SkyBlue1")
tk.Label(master, text="%s"%text,font=12,bg="SkyBlue1").grid(row=0,sticky="nesw")
tk.Label(master, text="First Name:",font=12,bg="SkyBlue1").grid(row=1,sticky=tk.W, padx=75)
tk.Label(master, text="Last Name:",font=12,bg="SkyBlue1").grid(row=2,sticky=tk.W, padx=75)
tk.Label(master, text="National Identity Number:",font=12,bg="SkyBlue1").grid(row=3,sticky=tk.W, padx=75)
tk.Label(master, text="Email Address:",font=12,bg="SkyBlue1").grid(row=4,sticky=tk.W, padx=75)
e1 = tk.Entry(master)
e2 = tk.Entry(master)
e3 = tk.Entry(master)
e4 = tk.Entry(master)
e1.grid(row=1, column=1,ipadx=50)
e2.grid(row=2, column=1,ipadx=50)
e3.grid(row=3, column=1,ipadx=50)
e4.grid(row=4, column=1,ipadx=50)
tk.Button(master, text='Send',font=12, command=validate_entry_fields).grid(row=5,column=1,sticky=tk.W, pady=5)
tk.mainloop()
Comments