Data Science Some Days: Let’s write an email

Ladies and gentlemen, this has been a long time coming.

So, I’ve finally started programming. Technically, I started months ago but I’ve made such a piss-poor effort at being consistent, that I’ve done next to nothing.

I was growing frustrated – often having nightmares asking the question – will I ever be able to say “Hello World”?

Evidently, simply thinking about it would never work. I can buy as many Udemy courses as I want – that won’t turn me into a data scientist. My wonderful solution to this is to go straight into a project and learn as I go. I’m learning python 3.6. But first…

print("Hello World")

I have joined the elites.


Ok, the project goes as follows:

I need to send emails to specific groups of people a week before the event starts. The email should also include attachments specific to the person I’m sending the email to and it will have HTML elements to it.

To break it down…

  • I need to send an email
  • I need to send a HTML email
  • I need to send a HTML email with attachments
  • I need to send a HTML email with attachments to certain people

There’s more but I’ve only managed the first two so far. This programming stuff is difficult and the only reason why I’m not computer illiterate is because I was born in the 90s.

I started off by opening these tutorials:

They’re both great and use slightly different methods to achieve the same result. Maybe you’ll notice that my final solution ends up being a desperate cry for help combination of them both.

LET US BEGIN.


Here is the first iteration of the code:

import smtplib
#sets up simple mail transer protocol

smtpObj = smtplib.SMTP('smtp-mail.outlook.com', 587)
type(smtpObj)
#Connects to the outlok SMTP server

smtpObj.ehlo()
#Says "hello" to the server

smtpObj.starttls()
#Puts SMTP connection in TLS mode.
#I didn't get any confirmation when I ran the program though...

smtpObj.login('email1@email.com', input("Please enter password: ")
#Calls an argument to log into the server and input password.

smtpObj.sendmail('email1@email', 'email2@gmail.com', 'Subject: Hello mate \nLet\'s hope you get this mail')
#Email it's coming from, email it's going to, the message

smtpObj.quit()
#ends the session

print('Session ended')
#Tells me in the terminal it's now complete


Boom, pretty simple right? I mainly took everything from Automate the Boring stuff and just swapped in my details. Well, of course not. I kept on getting an error – nothing was happening.

Well – I was somehow using the WRONG EMAIL. FUCK. It took me an hour to realise that.


Next step… let’s send an email with bold and italics.

This was frustrating because nothing worked. All it really requires is for you to put in the message in HTML format. Because I’m not learning HTML, I decided to just use this nifty HTML converter to make this part less painful.

Here are my errors…

#regularly get "Syntax error" with smtpObj.sendmail - I was missing a fucking bracket

This literally made me to go bed angry.


'''everything in the HTML goes into the subject line -
smtpObj.sendmail('email@email', 'email2@gmail.com', "Subject: " f"Hello mate \n {html}")'''

This was a surprise but I figured out to stop it…

'''Now nothing shows up in the body of the message:
smtpObj.sendmail('zctylak@ucl.ac.uk', 'oj.akhigbe@gmail.com', f"Subject: \n Hello mate {html}")
Solved by putting {html} next to \n'''

…then it somehow got worse…

'''Now... the email doesn't actually show up in html format
smtpObj.sendmail('zctylak@ucl.ac.uk', 'oj.akhigbe@gmail.com', f"Subject: Hello mate\n{html}")'''

…and even worse.


At this point, I changed tactic and, in the process, the entirety of my code. I won’t show you everything here otherwise this post will look too technical to those who have no experience with coding but I’ve uploaded my progress so far onto Github.

To summarise, rather than trying to send HTML with the technique I used earlier, I used a module that was essentially created to make sending emails with python much easier (email.mime). This essentially means, it contains prewritten code that you can then use to create other programs.

But… I was successful in sending myself a HTML email. Now the next step is to add a bloody attachment without putting my head through my computer.


Dear reader, you may be wondering, “why is he putting himself through so much suffering? He sounds incredibly angry.

I’m not, I promise. This has actually been the most fun I’ve had in my free time in a while. It was a good challenge and I could sense myself improving after every mistake.

Granted, I probably should have just completed an online course or something before trying to jump into this project but that would have been less fun.

Onto the next one…

Thanks for reading!

Am I a Fraud? | The Sunday Monday Post

Last year I wrote this:

“I thought I’d start the Sunday Monday Post so I can to talk more loosely about the things I’ve enjoyed within the self-improvement sphere and how I think I’ve improved in the past week (or since the time of the last edition).”

I’m not very good at this whole “writing weekly” thing. I live on a wheneverly schedule, I suppose.

To summarise, this is a far less structured post than normal and a chance to talk about what I’ve found interesting in the past week with regards to self-improvement.


The titular question – am I a fraud? – is a bit unfair because I’ve already answered it. I often believe that I am.

Writing about self-improvement, overcoming adversity (and daily mindfulness tips over on my Facebook page), seems to put me in a position of authority. If I write as if I know what I’m talking about, then I ask, do people believe that have everything under control?

I certainly hope not.

Sometimes I’m like the little kid, who has no sense of direction, crying for my parents in a grocery store. Other times, I surrender myself to death by Pringles overdose or drown in crunchy M&Ms .

One of the reasons why I am hesitant to post is that I feel like my posts … lack sincerity? Aren’t true?  I can’t find the right word. If I don’t always live the advice that I give, is it good advice? Am I ever in the position to give advice about anything at 22?

To tackle this, I try to remind myself of the highlight/blooper reel problem. We compare our bloopers to the highlights of other people. If I fear that other people would think I’m a fraud if they found out my bloopers, what does that mean?

It means that, because I write about self improvement, I have to not only present myself as a person who follows all of their advice but I have to be perfect. Which goes completely against the idea of improving slowly and self-compassion!

I don’t have to be perfect. I’m not perfect. I do not want to be perfect. But it’s OK to give recommendations on how to live better because I’m just here figuring it all out along with everyone who reads. You probably have a personal problem that other people do not know about. I do too. And that’s alright – you can still help others.


Even though the fear that other people think I’m better than I actually am is based on nothing factual, I’d like to break that down a bit. I’m going to share some of the positives and negatives I’ve had in the past month:

The good: 

  • I swam 1.5km quite a few times and it felt good.
  • I finished the first draft of my dissertation.
  • I worked on a summer school and seemed to make a positive impact on some of the students.

The bad: 

  • I didn’t write for the blog as consistently as I would have liked.
  • I also struggled to swim 700m multiple times throughout the month.
  • I broke promises to call friends to catch up.

The ugly: 

  • I’ve been in a lot of pain, nearly every day.
  • I’ve polished off 3 packets of Pringles in a week (and m&ms … I told you.) as a result. Stress eating is something I’ve tried to avoid but it sometimes catches up with me.
  • I’ve been overwhelmed with negative emotions that make me withdraw from other people quite quickly.

Despite all of the articles on self-improvement I’ve written, I still make a lot of mistakes. It’s just part of the process. Social media makes it really easy for us to believe that things are smoother than they really are.

So I’ll try to worry less about whether I have the “authority” to help people. A lot of these articles are also reminders to myself.

I hope you find them helpful too!


Here are a few articles I’ve found interesting in the past week:

And that brings me to the end of the Sunday Monday Post.

How do you manage the feelings of insecurity and helping other people? Does it bother you at all?

As always, thanks for reading.

For more updates, you can follow me on Facebook and Twitter!

The Excuse not to Try

An excuse not to try is needlessly self-limiting.

It takes a desire, bathes it in fear and tells you ‘no, don’t bother. Your efforts will be wasted’. Evidence is non-existent but your belief in it is high.

What is an excuse not to try?

It’s a weak rationalisation for not doing something you want to do. They usually take a very general form that can be applied to anything rather than specific to your personal situation.

For example:

“I don’t have time…”

“I’m going to do poorly…”

“I haven’t planned anything yet…”

There are many others of this form and there’s a reason for that. They are quite lazy and don’t assess the situation properly.

Here’s an example:

Emily wants to join her university’s football society but chooses not to because she’s never played before and doesn’t want to make a fool of herself.

We have some facts: she wants to join and she’s new to football.

However, she’s made some suspicions that are wrongly taken as fact.

Firstly, that she’ll make a fool of herself. Secondly, that making a fool of yourself is going to be bad. Nothing says she can’t continue to enjoy it. Thirdly, other people won’t be in a similar situation.

The reasons for believing these things are powerful. The image of herself running, falling and getting hit on the head with the ball are potent. They replay in her head many times becoming more powerful each time. She’s already embarrassed before even looking at the sign-up sheet.

If these things aren’t true, what other reason does she have to not try for something she wants?

None.

She can try, overcome the fear and hopefully have fun. If it doesn’t turn out the way she desires, at least she knows why rather than living with ‘what ifs’.

Excuses and Reasons

If we take these excuses seriously and put pressure on them, we find out two things.

  1. They shouldn’t stop us from trying; or
  2. They are justified as actual reasons rather than excuses

Both can be very valuable.

The first is liberating. It gives us the power to follow the things we want rather than being crippled with fear.

To end the excuses we can do a few things:

  1. Find a solution

Want to write more? Set aside 10 minutes every day.

Eat too many biscuits? Simply stop buying them.

  1. Be aware of the excuse

Knowing you’re making an excuse rather than giving a valid reason is useful. Excuses can be so automatic we never put pressure on them.

  1. Ignore the excuse and do it regardless

Put the excuse in a bubble, label it as an annoying pest and do it. There have been times when I’m writing while telling myself I don’t have the energy. Then I realise how silly that sounds.

The second is useful. It puts us in the position to assess our priorities and admit that some things are more important than others. We then put our attention towards fewer things and do a better job in the process. If your justification for not doing it becomes more specific, then it becomes a valid reason rather than an excuse thrown at a problem to avoid slight discomfort.

In short, we actually think about whether we’re being honest to ourselves.

Excuses not to try stop us from achieving things we actually want.

Thankfully, it doesn’t need to be that way.

We can rid ourselves of the excuse not to try and finally start making some progress.

Is there a big difference between an excuse and a reason? Are you making an excuses not to try something?

Share this on Facebook or Twitter.


This shouldn’t be taken as a manifesto to do everything.

There are good reasons for not doing things. For example, not wanting to smoke because of the poor health implications is not a flimsy excuse. Finding these reasons can even start us on the path to actually achieving the things we want. Being unable to travel because of money problems gives us the opportunity to start saving for it in the future.

Excuses in general are a slightly different problem. The excuse not to try prevent us from doing things we want. Excuses can also cover things we should probably do but want to avoid (like exercise). I’ll get to that another time.


In other news, I’ve rid myself of the excuse not to try a newsletter. So I made one.

You can subscribe HERE.

To start with, it’ll be about once a fortnight if I keep up my writing. I hate spam too, don’t worry.


Other stuff to read:

99 reasons for NOT making ideas happen

Let the Fear Pass

How to Kill your Excuses

Again, newsletter subscription HERE.

Why you’ll fail your new years resolutions

They are created impulsively.

They are vague.

They are unplanned.

They are too big.

They are ultimately unimportant to you.

Many goals start off in such a fashion. Our pursuit of them works for a short while because we’re still in the ‘This year is a new me!’ stage. We have vast amounts of motivation because we now write 2014 instead of 2013.

After all, that was the push we needed to pursue the change we want. A change of date.

When we make new resolutions on new years, we attempt to change almost instantly. If you’ve been eating bad food for years, why would it be easy for you to change your mindset towards food in a day? If you spend all your days sitting down, why would it be easy to start a rigorous exercise regime after a New Years party?

We move far too quickly with no real direction when we attempt to complete our new years resolutions. It’s why the gym is packed to the brim in January but quickly empties during February. They’ve probably told everyone about their new goals which leads them to feeling slightly accomplished about their goals (even if they’ve done very little). No one will ask for a follow up on their friend’s progress because they have better things to do. Then they’ll look back on the statement they made at the beginning of January and realise they haven’t stepped into the gym for over 6 months.

How do you stop that from happening this year?

Making valuable progress towards your goal 

  1. Start small

This is probably the most important thing you can do if you want to make progress. It makes it much more difficult for you avoid and much easier to make steady progress towards a goal. Focusing on one goal is much better than making a weak effort towards five foals.

2. Focus on a routine rather than the goal

This emphasises consistency. Working on building a reliable routine more than you do a goal means you’re more likely to work towards it steadily throughout the year instead of making random bursts of effort towards it.

If you want to improve your writing over the next year, make sure your routine involves writing regularly (if not everyday). If you want to lose weight (or gain muscle), make sure your routine involves going to the gym at least 4 times a week.

3. Make your goals specific

No more ‘I want to be happy’ or ‘I want to be a better person’. If you want to improve your grades in school, say what grades and by how much. If you want to lose weight, say how much and how you’ll do it.

A new year is not the reason why you’ll become a better person. You are. You shouldn’t depend on motivation throughout the whole year because it burns out quickly.

Start small, remain consistent and that’s the way we make progress.

Are you keeping any resolutions for the new year?