File Attachment Mail Message

Last post 12-01-2010 15:43 by ctacke. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-29-2009 9:04

    File Attachment Mail Message

    I must be missing something really basic here.  How do I add a file attachment...

     

    SmtpClient client = new SmtpClient(SmtpServer);

    MailMessage mailMessage = new MailMessage(FromEmailAddress, ToEmailAddress);

    mailMessage.Body = body;

    mailMessage.Subject = subject;

    mailMessage.BodyEncoding =
    Encoding.ASCII;

    mailMessage.SubjectEncoding = Encoding.ASCII;

    mailMessage.Attachments.Add(......... 

     

    Filed under:
  • 04-30-2009 7:19 In reply to

    • neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,349

    Re: File Attachment Mail Message

    mailMessage.Attachments.Add(new Attachment(fileName)); is one possible scenario. The Attachment class inherits from the abstract AttachmentBase class. See the documentation for all the possible constructors.

    Neil Cowburn
    OpenNETCF Consulting

      
  • 04-30-2009 9:14 In reply to

    Re: File Attachment Mail Message

    Like I said maybe I am missing something but here is the Attachment class...
    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace OpenNETCF.Net.Mail
    {
        /// 
        /// Represents an attachment to an e-mail.
        /// 
        public class Attachment
        {
            //TODO Currently not supported
            internal void Dispose()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }
    }
    
    It does not extend AttachmentBase like I thought it would...The is in OpenNETCF.Net.Mail...
  • 05-01-2009 5:43 In reply to

    • neil
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-30-2007
    • North Wales
    • Posts 1,349

    Re: File Attachment Mail Message

    I just checked the source in TFS and yep, it's stubbed out but not implemented. If you'd like to report this as a bug, we can then track it. 

    Neil Cowburn
    OpenNETCF Consulting

      
  • 10-05-2009 9:16 In reply to

    Re: File Attachment Mail Message

    Any ETA on when this fix will be implemented. Kinda need this as my own hand-rolled SMTP class is not working and trying to avoid using PocketOutlook as the people using the device will abuse the email.

  • 10-05-2009 9:24 In reply to

    Re: File Attachment Mail Message

     The bug was reported in May.

     http://bugzilla.opennetcf.com/show_bug.cgi?id=376

    Perhaps a nice work around will be to make use of the PocketOutlook Attachment class.

    This will allow the following code to work

                 Microsoft.WindowsMobile.PocketOutlook.Attachment att = new Microsoft.WindowsMobile.PocketOutlook.Attachment(@"\test.txt");

                 msg.Attachments.Add((OpenNETCF.Net.Mail.Attachment) (att));

    Dunno how possible this is. Becoming rather urgent on this.

  • 02-04-2010 9:35 In reply to

    Re: File Attachment Mail Message

    Is there a solution for that bug ?

    it seems the workaround doesn' work (conversion not possible)

    :-) Michael

  • 12-01-2010 15:16 In reply to

    Re: File Attachment Mail Message

     Is there a time frame for when Attachments to emails are going to be supported?   This is a pretty serious feature to leave out.  Is it even being considered for the next release of the SDK.    The OpenNet SDK fills in some big gaps in the .NET Compact Framework, but it is very frustrating when you find out these hidden unimplemented features that make it practically useless.

  • 12-01-2010 15:43 In reply to

    • ctacke
    • OpenNETCF Staff
    • Top 10 Contributor
    • Joined on 07-27-2007
    • Indiana
    • Posts 2,254

    Re: File Attachment Mail Message

    I don't have a time frame for it, no.  In fact this is, I believe, only the third time it's been asked about in something like 5 years.

    Attachments are fairly simple - you simply would make the format of the body MIME, set the content-type to mime/multipart and assemble the pieces.

Page 1 of 1 (9 items)