none
EWS C# Attachment Question RRS feed

  • Question

  • I am using the following code to get attachments from an email message. Thing is I have about six places in my overall code page that uses the same code.

    I don't now what to put in for the ???? from my EmailMessage mail statement.

    What should I put where I have EmailMessage m in the second statement.

    Thanks for the help.

    sqlattachments(????, Convert.ToInt32(ticketnumber), currenticket, ticketreceived);
    
    private void sqlattachments(EmailMessage m, int mticketid, string mticketstring, DateTime mreceived)
            {
                foreach (Attachment attachment in m.Attachments)
                {
                    if (attachment is FileAttachment)
                    {
                        FileAttachment fileAttachment = attachment as FileAttachment;
    
                        // Stream attachment contents into a file.
                        string filepath = "\\\\pacvsiis02\\c$\\inetpub\\tickets\\attachments\\" + mticketstring + "\\";
                        Directory.CreateDirectory(filepath);
                        FileStream theStream = new FileStream(filepath + fileAttachment.Name, FileMode.OpenOrCreate, FileAccess.ReadWrite);
                        fileAttachment.Load(theStream);
                        theStream.Close();
                       theStream.Dispose();
    
            
                    }
                    else
                    {
    
                    }
                }
    
            }

    Friday, October 31, 2014 12:40 PM

All replies