System.Web.Mail and PDF getting corrupted workaround

I was troubleshooting an issue where I was sending an email using .NET 1.1 and attaching PDF files. The PDF files where getting an error when trying to open the attachment.  Here is what was displayed in Adobe reader.  "There was an error processing a page. A file I/O error has occurred".  Thanks a bunch to Dave Wanta, creator of for providing a great resource about System.Web.Mail ( ).  A similar example worked in ASP.NET 2.0, comparing email headers provided the clues it was how the attachment was getting encoded.  I found the answer in the article listed below.

This article explains it. 

The bolded code is what you have to alter

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.Mail" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<script runat="server">

protected void Page_Load(object sender, EventArgs e)

    string FilePath = Request.PhysicalApplicationPath + "/c.pdf";
    MailMessage msgMail = new MailMessage();

    msgMail.To = "[email protected]";
    msgMail.From = "[email protected]";
    msgMail.Subject = "Your Favorite Subject";
    msgMail.Body = @"Some Text goes here";
    msgMail.Attachments.Add(new MailAttachment(FilePath, MailEncoding.UUEncode));
    Response.Write("Thank you."); 


<html xmlns="" >
<head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">

Hope this helps

Steve Schofield
Microsoft MVP – IIS