The implementation you linked shows how to send the calendar entry as an alternative view, not as an attachment. I'm guessing that you also want people to see it as an attachment. In that case you just need to attach a file to the same message:
msg.Attachments.Add(Attachment.CreateAttachmentFromString(
str.ToString(), "Appointment Reminder.ics"));