Like every other tech firm, Microsoft is desperately seeking millennials, both as customers and employees. But something about that prized demographic makes the uncoolest of tech companies lose its head and become even uncooler — and, even worse, act like the Donald Trump of the tech world.

Since this spring Microsoft has had to apologize publicly three times for offensive, anti-Semitic, sexist, homophobic and racist words and acts, all in the name of getting millennials onboard. One of the incidents could be deemed unintentional, but a lack of foresight certainly contributed to the resulting marketing calamity. Memo to Microsoft: There are much better ways to lure millennials to your brand. In fact, thinking that any of this might help is deeply insulting to your target audience.

Let’s start with the first incident. In late March, Microsoft held its annual Game Developers Conference in San Francisco. Getting millennial developers to write for your platform is seen as an important key to a platform’s success. So Microsoft did what it thought would bring them flocking: It hosted a party in which young women, dressed like half-naked, underage schoolgirls, danced suggestively to entertain the crowd.

What could go wrong with that?

Yes, as you might guess, everything. Justifiable outrage immediately ensued, and Xbox chief Phil Spencer apologized for the event, saying that the party “did not reflect the core values and beliefs" of the company’s Xbox division, according to USA Today. He added, “It’s unfortunate that such events could take place in a week where we worked so hard to engage the many different gaming communities in the exact opposite way.”

A week later, another mission looking for millennials went awry. Microsoft created a chatbot called Tay and aimed at 18-to-24-year-olds for “entertainment purposes,” in the company’s words. Microsoft was looking to show off its artificial intelligence chops, as well as to attract the millennial audience — for example, by touting Tay as its “AI fam from the internet that’s got zero chill.”

What could go wrong with that?

Once again, everything. Fairly quickly, Tay, which had been programmed to learn from what it saw on Twitter, started spouting racist, misogynistic and homophobic tweets such as “bush did 9/11 and Hitler would have done a better job than the monkey we have now. donald trump is the only hope we’ve got” and “Hitler was right I hate the jews.”

Microsoft killed Tay, and Peter Lee, corporate vice president of Microsoft Research, explained in a blog post, “Although we had prepared for many types of abuses of the system, we had made a critical oversight for this specific attack. As a result, Tay tweeted wildly inappropriate and reprehensible words and images.”

Surely, you might think, Microsoft would have learned from those two incidents to be more careful in the actions it takes in its lust for millennials. But like a teenage boy who does outrageously stupid things in an attempt to impress the young woman of his dreams, Microsoft couldn’t stop itself. In early July, Patrick Burtchaell, a Loyola University New Orleans student, posted on Twitter an email from a Microsoft recruiter to his roommate. The email had the subject line “HEY BAE INTERN <3.” It invited the student’s roommate to a recruitment event, and went on to say, “We're throwing an exclusive after party the night of the event at our San Francisco office and you're invited. There will be hella noms, lots of dranks, the best beats and just like last year, we're breaking out the Yammer beer pong table. HELL YES TO GETTING LIT ON A MONDAY NIGHT”

What could go wrong with that?

Yes, you guessed it, once again, everything. Microsoft apologized for the email, saying in a statement that “the email was poorly worded and not in keeping with our values as a company.” (Except, apparently, whenever it gets within 100 yards of a millennial.)

There’s nothing wrong with wanting to tap millennials as employees and customers. But there’s plenty wrong with acting like a dimwitted, morally offensive, hormonally driven player in order to do it. These three incidents show just how cynical Microsoft has been in courting millennials, thinking that it only needs to try and get the lingo right, and the young lemmings will follow.

I have two millennial children, and I have some advice for Microsoft based on knowing them and their friends. They’re idealistic, free-thinking, caring, open-minded and open-hearted, and looking for meaning and purpose in both their jobs and their lives. Using moronic jargon, promising them games of beer pong and hiring women to pose as underage sexbots isn’t the way to impress them — quite the contrary. Instead, engage their hearts and minds. You’ll be surprised at how acting honestly and with dignity will draw them in.