Using AppleScript to mail merge with attachments

Here is some code that is useful for sending batch emails with Mac Mail to recipients using information stored in a text file. This also enables attaching specific files to the message, again based on the information in the text file.


set mol_list to {}
-- This will ask you to select a file containing the intended recepients and their emails --
-- I also include in this file information needed to link to an attachment --
set theFile to choose file with prompt "Select a text file:"
set theFileReference to open for access theFile
-- Note that the line end here is an old Mac return (not MSFT carriage return) --
set theFileContents to read theFileReference using delimiter return
close access theFileReference

-- Now parse the file that was selected. Here I'm parsing a tab-delimited file. --
set text item delimiters to tab
-- Loop through the file one line at a time --
repeat with i from 1 to count of theFileContents
    set theLine to text items of item i of theFileContents
    copy theLine to the end of mol_list
    -- this identifies each column in the tab-delimited file --
    set stid to item 1 of theLine
    set first_name to item 2 of theLine
    set last_name to item 3 of theLine
    set email_add to item 4 of theLine
    -- specify the location of the file to attach --
    -- here I'm pasting together information from the tab-delimited file to point to the file for this particular recipient --
    set file_attach to "Macintosh HD:Users:USERID:file_" & stid & ".pdf"
    -- Set the message, again pasting together info from the recipient file --
    set message_content to "Dear " & first_name & ",
   
    This is my email to you containing your information.
   
    Andrew
   
    "
    -- Now push this to Mac's mail software
    tell application "Mail"
        -- Create a new message with the message above and the subject --
        set theMessage to make new outgoing message with properties {visible:true, subject:"Set the subject here", content:message_content}
        -- Set the address for this recipient --
        tell theMessage
            make new to recipient at end of to recipients with properties {address:email_add}
        end tell
        -- Add the attachment to this recipient --
        tell content of theMessage
            make new attachment with properties {file name:file_attach as alias} at after last paragraph
        end tell
       
        -- Add a little delay to attach larger files to the email before sending --
        delay 2
       
        -- Send the message to this recipient --
        send theMessage
    end tell
   
end repeat

Using recurrence analysis to examine group dynamics

Knight, A. P., Kennedy, D. M., McComb, S. A. (2016). Using recurrence analysis to examine group dynamics. Group Dynamics: Theory, Research, and Practice, 20, 223-241.

Abstract. This article provides an accessible introduction to recurrence analysis—an analytical approach that has great promise for helping researchers understand group dynamics. Recurrence analysis is a technique with roots in the systems dynamics literature that was developed to reveal the properties of complex, nonlinear systems. By tracking when a system visits similar states at multiple points in its life—and the form or pattern of these recurrences over time—recurrence analysis equips researchers with a set of new metrics for assessing the properties of group dynamics, such as recurrence rate (i.e., stability), determinism (i.e., predictability), and entropy (i.e., complexity). Recent work has shown the potential value of recurrence analysis across a number of different disciplines. To extend its use within the domain of group dynamics, the authors present a conceptual overview of the technique and give a step-by-step tutorial on how to use recurrence analysis to study groups. An exemplar application of recurrence analysis using dialogue-based data from 63 three-person student groups illustrates the use of recurrence analysis in examining how groups change their focus on different processes over time. This is followed by a discussion of variations of recurrence analysis and implications for research questions within the literature on groups. When group researchers track group processes or emergent states over time, and thus compile a time series dataset, recurrence analysis can be a useful technique for measuring the properties of groups as dynamic systems.

The impact of environment and occupation on the health and safety of active duty air force members

Erich, R., Eaton, M., Mayes, R., Pierce, L., Knight, A. P., Genovesi, P., Escobar, J., Mychalczuk, G., Selent, M. (2016). The impact of environment and occupation on the health and safety of active duty Air Force members: Database development and de-identification. Military Medicine, 181, 821-826.

Abstract. Preparing data for medical research can be challenging, detail oriented, and time consuming. Transcription errors, missing or nonsensical data, and records not applicable to the study population may hamper progress and, if unaddressed, can lead to erroneous conclusions. In addition, study data may be housed in multiple disparate databases and complex formats. Merging methods may be incomplete to obtain temporally synchronized data elements. We created a comprehensive database to explore the general hypothesis that environmental and occupational factors influence health outcomes and risk-taking behavior among active duty Air Force personnel. Several databases containing demographics, medical records, health survey responses, and safety incident reports were cleaned, validated, and linked to form a comprehensive, relational database. The final step involved removing and transforming personally identifiable information to form a Health Insurance Portability and Accountability Act compliant limited database. Initial data consisted of over 62.8 million records containing 221 variables. When completed, approximately 23.9 million clean and valid records with 214 variables remained. With a clean, robust database, future analysis aims to identify high-risk career fields for targeted interventions or uncover potential protective factors in low-risk career fields.

Spring 2017 Courses

Organizational Research Methods (PhD), January to May, 2017

This is an introductory PhD seminar on organizational research methods. In this course we will together critically examine the building blocks of rigorous research and publishing in the organizational sciences, across a range of research questions and specific research methods. We will do this through readings, class discussions, and exercises, as well as through writing and reviewing one another’s work.

Key Learning Objectives

  • Expose you to a range of methods commonly-used by organizational scholars, helping you to learn the language and foundations of dominant methodological approaches.
  • Improve your ability to critically consume organizational research from a variety of methodological approaches.
  • Provide you with different methodological tools that may be useful for your own research interests and questions.
  • Develop your ability to identify the strengths and weaknesses of research, as well as the tradeoffs that scholars make in the research and publication process.
  • Strengthen your ability to communicate your ideas, interests, and contributions through your writing.

Fall 2016 Courses

Foundations for Effective Leadership (MBA), August to September, 2016

The focus of this 1st year Core MBA course is you–your characteristics, your attributes, and your interpersonal skills. This course presents a framework for thinking about how individual attributes and and interpersonal skills provide leadership potential. Through experiential exercises and interactions with your colleagues, this course will enable you to gain deeper insights into your current strengths as a leader and developmental opportunities for the future.

Key Learning Objectives

  • Deepen your self awareness by enhancing your insight into (1) your personal characteristics and attributes; (2) your interpersonal, social, and leadership skills; and, (3) your approach in working in groups and teams.
  • Improve your leadership effectiveness by enhancing your capacity to (1) identify your own leadership strengths and weaknesses and (2) understand how your assets and liabilities combine with others’ in groups and teams.

The effects of group affect on social integration and task performance

Knight, A. P., & Eisenkraft, N. (2015). Positive is usually good, negative is not always bad: The effects of group affect on social integration and task performance. Journal of Applied Psychology, 100, 1214-1227.

Abstract. Grounded in a social functional perspective, this article examines the conditions under which group affect influences group functioning. Using meta-analysis, the authors leverage heterogeneity across 39 independent studies of 2,799 groups to understand how contextual factors—group affect source (exogenous or endogenous to the group) and group life span (one-shot or ongoing)—moderate the influence of shared feelings on social integration and task performance. As predicted, results indicate that group positive affect has consistent positive effects on social integration and task performance regardless of contextual idiosyncrasies. The effects of group negative affect, on the other hand, are context-dependent. Shared negative feelings promote social integration and task performance when stemming from an exogenous source or experienced in a 1-shot group, but undermine social integration and task performance when stemming from an endogenous source or experienced in an ongoing group. The authors discuss implications of their findings and highlight directions for future theory and research on group affect.

Group affect

Barsade, S. G., & Knight, A. P. (2015). Group affect. Annual Review of Organizational Behavior and Organizational Psychology, 2, 21-46.

Abstract. Over two decades of research has indicated that group affect is an important factor that shapes group processes and outcomes. We review and synthesize research on group affect, encompassing trait affect, moods, and emotions at a collective level in purposive teams. We begin by defining group affect and examining four major types of collective affective constructs: (a) convergence in group affect; (b) affective diversity, that is, divergence in group affect; (c) emotional culture; and (d) group affect as a dynamic process that changes over time. We describe the nomological network of group affect, examining both its group-level antecedents and group-level consequences. Antecedents include group leadership, group member attributes, and interactions between and relationships among group members. Consequences of group affect include attitudes about the group and group-level cooperation and conflict, creativity, decision making, and performance. We close by discussing current research knowns, research needs, and what lies on the conceptual and methodological frontiers of this domain.

Who defers to whom and why?

Joshi, A., & Knight, A. P. (2015). Who defers to whom and why? Implications of demographic differences and dyadic deference for team effectiveness. Academy of Management Journal, 58, 59-84.

Abstract. We develop and test predictions about how demographic differences influence dyadic deference in multidisciplinary research teams, and how differential patterns of dyadic deference emerge to shape team-level effectiveness. We present a dual pathway model that recognizes that two distinct mechanisms—task contributions and social affinity— account for how team members’ demographic attributes contribute to deference. Furthermore, we propose that the extent to which these different mechanisms are prevalent in a team has implications for the team’s research productivity, with deference based on social affinity detracting from it and deference based on task contributions enhancing it. Using longitudinal data from a sample of 55 multidisciplinary research teams comprising 619 scientists, we found general support for our conceptual model. Our findings underscore the importance of accounting for multiple interpersonal mechanisms to understand the complex, multilevel nature of deference in teams.

Affect and change in exploratory search over time

Knight, A. P. (2015). Mood at the midpoint: Affect and change in exploratory search over time in teams that face a deadline. Organization Science, 26, 99-118.

Abstract. The purpose of this paper is to advance the team dynamics and group development literatures by developing and testing a theoretical model of how affect shapes transitions in teams over time. Integrating the group transitions literature with theory and research on the mood-as-input theory, I propose that shared team mood influences the extent to which team members seek out and experiment with alternative ways of completing their work at different points in a team’s life. In the first half of the team’s life, when team members are relatively task-focused, I argue that team positive mood (i.e., a positively valenced affective state shared by team members at a given point in time) stimulates, whereas team negative mood (i.e., a negatively valenced affective state shared by team members) suppresses, exploratory search. At the temporal midpoint, however, when team members’ focus on performance heightens, team positive mood acts as a shutoff switch for search, leading to a decline in exploratory search over the second half of the team’s life. Team negative mood at the midpoint, on the other hand, leads team members to persist in exploratory search, even as a deadline draws near. A team’s trajectory of exploratory search over time, I propose, influences team performance such that it is highest when teams engage in high exploratory search early in the team’s life and decline in exploratory search over the second half of the team’s life. The results of a longitudinal, survey-based study of teams preparing for a military competition largely support my predictions.

The effects of a non-sedentary workspace

Knight, A. P., & Baer, M. (2014). Get up, stand up: The effects of a non-sedentary workspace on information elaboration and group performance. Social Psychological and Personality Science, 5, 910-917.

Abstract. Non-sedentary work configurations, which encourage standing rather than sitting in the course of work, are becoming increasingly prevalent in organizations. In this article, we build and test theory about how non-sedentary arrangements influence interpersonal processes in groups performing knowledge work—tasks that require groups to combine information to develop creative ideas and solve problems. We propose that a non-sedentary workspace increases group arousal, while at the same time decreasing group idea territoriality, both of which result in better information elaboration and, indirectly, better group performance. The results of an experimental study of 54 groups engaged in a creative task provide support for this dual pathway model and underscore the important role of the physical space in which a group works as a contextual input to group processes and outcomes.