04 June 2017

How to find the correct SMTP server settings so that you can Send Mail As from Office365 in Gmail

One of Gmail's (many) cool features is that it lets you check mail from other non-Gmail addresses and send mail from other addresses that you own. This allows you to manage all of your email from a single interface, and extends all of the benefits of Gmail to mail from your other non-Gmail accounts (labels, Google-powered search, etc.).


Set up Send Mail As

Here are Google's instructions for how to set up sending emails from a different address in Gmail:

Step 1: Add an address you own
  1. On your computer, open Gmail.
  2. In the top right, click Settings.
  3. Click the Accounts and Import or Accounts tab.
  4. In the "Send mail as" section, click Add another email address.
  5. Enter your name and the address you want to send from.
  6. Click Next Step.
  7. Enter the SMTP server (for example, smtp.domain.com) and the username and password on that account.
  8. Click Add Account.
Step 2: Confirm the address
  1. Sign in to the account you added.
  2. Open the confirmation message you got from Gmail.
  3. Click the link.
Step 3: Change the "From" address
  1. In the message, click the "From" line.
    (If you don't see this, click the space next to the recipient's email.)
  2. Select the address to send from.


Uh-oh, errors

When it works, it is a thing of beauty. The problem is that for some email addresses, these default steps do not cut it. This is particularly the case for Microsoft Exchange or the newer Office365 email addresses. Users with Microsoft work email addresses tend to run into trouble at step 1.7 when attempting to specify the SMTP server.

I have come across two errors. The first appears when using the default SMTP address without making any changes:
Couldn't reach server. Please double-check the server and port number.

Another error message came up when I used the recommended SMTP server for Office365 users (which is smtp.office365.com):
Authentication failed. Please check your username/password.
Server returned an error: "334 VXNlcm5hbWU6 334 UGFzc3dvcmQ6 535 5.7.3 Authentication unsuccessful [CY4PR16CA0035.namprd16.prod.outlook.com] code(535) "

Some people claim to have come across an error saying Server response: read error code(0), although I have not seen that error, myself.


So, what's the problem?

The problem is obviously that I was not specifying the correct SMTP server. You might think that the first step should be to contact IT support at work to obtain the correct SMTP address. IT Support do not understand what you are trying to do. They might tell you to use the recommended email client (most likely Outlook). You re unlikely to find a solution this way.

For me, this was very frustrating and led to a lot of searching and trawling through forums, trying to find a solution. The issue arises from the fact that the recommended SMTP server (smtp.office365.com) is not the final destination, but rather redirects to another SMTP server address based on your location (similar to how typing in Google.com will redirect you to Google.co.uk in England, but to Google.com.au in Australia).


How to find your Office365 SMTP server

In order to find your SMTP server, you must ping the smtp.office365.com address. And it is really easy to do.

On Mac, open Network Utility, click on the Ping tab, then enter the network address to ping, and click the Ping button. After a few seconds, a report will be generated, and at the top it will output something like this:
Ping has started…

PING outlook-au.office365.com

You could also open a Terminal window and type ping smtp.office365.com and then press Enter. After a few seconds it will start generating output. On the top line will be something like this:
PING outlook-au.office365.com

On Windows, open a Command Prompt window and type ping smtp.office365.com and then press Enter. It will start generating output, and the top line will look something like this:
Pinging outlook-au.office365.com

My particular SMTP server is outlook-au.office365.com. Entering this address as the SMTP server, my full Office365 email address as the username, and password worked when adding my Office365 address to Gmail.


07 April 2017

How to use Pivot Tables in Excel

Excel can be used to conduct some pretty advanced statistical analyses and data visualisations. My favourite, and most commonly used feature is the Pivot Table. The data in a Pivot Table can be restructured very easily and counts, averages and other calculations can be worked out quickly. It is often desirable to enter data from scientific experiments into a Pivot Table so that different conditions can be compared, some conditions or participants or trials can be excluded, and data can be collapsed or combined in a number of ways. But, for all of their usefulness, getting the data in to a format that can be read by a Pivot Table can be time consuming. Some experiment presentation/management programs, such as E-Prime, generate result files for individual participants. In order to generate a Pivot Table report, all data needs to be entered into a single Excel worksheet.

Here are the steps necessary to generate a Pivot Table in Excel:

1. Export the results files into a format that can be imported into Excel
Some experimental software outputs results in plain text format or as .csv files. These can be imported into Excel without any extra work. However, some software outputs results in a proprietary format that must be converted before Excel can read the data.

E-Prime: Open the .edat2 file in E-DataAid, and export to Excel format. For example, you would export participant1.edat2 as participant1.edat2.txt.

Hint: If you have many E-Prime data files, open these in E-Merge and create a merge file containing data for all of the participants. Then open the merge file using E-DataAid and export it to Excel format.

2. Open the text file in ExcelOpen the new .txt files in Excel (you can either select File | Open or drag and drop the file into Excel).

3. Go through the Text Import Wizard


In Step 1, select Delimited and click Next.




In Step 2, check the Tab option from the list of Delimiters and click Finish.

4. Delete Row 1
By default, E-Prime outputs the file path in the first line of the .txt file, which becomes row 1 when you import it into Excel. Delete it. This will cause row 2 to move up. Now row 1 contains your column headings which will become your Pivot Table fields.

5. Create a Pivot Table
Select all active columns. To do this, click on column A (by clicking on the A) and hold down the Shift key and click on the column label of the right most column (mine is HZ). This can be done using the keyboard by pressing Command+Shift+right arrow while column A is selected.


Click on the Insert ribbon and then Pivot Table. When the Create Pivot Table dialog appears, click OK.

6. Build your Pivot Table
Drag the fields that you are interested in into the Rows, Columns or Values areas. Subject/participant normally goes into the Rows area. The measures of interest (e.g., accuracy or reaction time data) usually go into Values.

When you first drag a field into Values, Excel will show you the count of how many data points there are. Click on the "i" next to the field within the Values area to show the Pivot Table Field window.


This gives you options to calculate the sum, average, maximum, minimum, standard deviation and so on. For experimental data, most of the time, we are interested in averages.

Spend time playing around with the fields in the Pivot Table Builder. You can explore your data in powerful ways, such as by isolating particular subjects, conditions, or cases.



Clicking on the inverted triangle next to Row Labels brings up the Row window which permits you to sort the rows, add filters, and exclude individual cases. This can be handy for exploring potential outliers (when looking at subjects), or examining performance for particular conditions or stimulus tokens.

Pivot Tables are great tools for exploring your data. They offer a degree of flexibility that is unmatched. They are very useful for answering "What happens if..." questions, and the calculations can be done very quickly.

25 January 2017

Zotero minimalist referencing style for grant applications

I use a custom Zotero referencing style when writing grant applications. It is designed to save space, and uses the following features:

  • In-text citations are denoted by superscript numerals
  • Reference list has single line spacing
  • No journal article titles
  • Journal names are abbreviated
  • No journal issue numbers
  • ≥ 3 author names are listed as "et al."

After each reference, I have inserted two forward slashes to demarcate separate references. I have also bolded the numeral that precedes each reference.

Once the reference list has been created, you may delete the carriage returns so that each reference does not take a new line.

My grant writing Zotero referencing style can be downloaded here.