Luke Joseph Posted September 11, 2019 Share Posted September 11, 2019 I have created a dashboard that allows users to monitor health surveillance testing for employees. There are 4 different segments being reported on and each segment is triggered by a due date which isusually 60 days before the testing is due - the status then automatically changes to "requires assessment". All of the employees in the list (data table) that have "requires assessment" next to their name will then need to be notified that their health testing is due and to inform them on how to get it tested.I have already created an expression for this in a separate column called "EmailBody" which has all of the above necessary information to be sent out. I then added another column to the data table from a different information link which is called"personnel email address". Theproblem I have now is trying to get the script to send notifications to the email addresses related to the people that have "requires assessment" next to their name. the script is below: from System import Array from Spotfire.Dxp.Data import IndexSet from Spotfire.Dxp.Data import DataValueCursor import datetime import clr clr.AddReference("Microsoft.Office.Interop.Outlook") from System.Runtime.InteropServices import Marshal columnName = 'EmailBody' for myTable in Document.Data.Tables: if myTable.Name == "ODRInformation Dashboard": rowCount = myTable.RowCount rowsToInclude = IndexSet (rowCount,True) #B create a cursor to the columnName column we wish to get values from cursor1 = DataValueCursor.CreateFormatted(myTable.Columns[columnName]) #C loop through all rows, retrieve value for specific column, and add value into dictionary #keys=dict() count = 0 for row in myTable.GetRows(rowsToInclude,cursor1): mail= Marshal.GetActiveObject("Outlook.Application").CreateItem(0) strEmailText ="" value1 = cursor1.CurrentValue if value1 != "NO_EMAIL": strEmailText = value1 strEmailText #create e-mail #for email in Document.Properties["strEmailTo"]: mail.Recipients.Add = 'Calculated Employee Email Address' mail.Subject = "NO REPLY - Your Health Surveilance Testing is Due Within 60 Days " mail.Body = strEmailText mail.Send() The problem are for me is "mail.Recipients.Add = ' which I have highlighted in bold. I'm not sure what to input here as I have created the "personnel email address" column but it can't read from just a column. Any help is appreciated. Thanks Link to comment Share on other sites More sharing options...
Khushboo Rabadia Posted September 30, 2019 Share Posted September 30, 2019 You can add personalemail column in the same table matching on employee name from both tables. Then as you have added cursor for column name, similarly add another cursor for emailaddress cursor2 = DataValueCursor.CreateFormatted(myTable.Columns[EmailAddress]) Then you can include the above cursor in getrows method: for row in myTable.GetRows(rowsToInclude,cursor1,cursor2) Then in recepient address, you can use the currentvalue of cursor 2 recepadd=cursor2.CurrentValue mail.Recipients.Add = recepadd Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now