Attachment problem

I have an asp.net application. This application will be generating a lot of Html files( Content as stream, and Html Name). I have to email these file to respective client. After testing it i happen to get the The attachment content in the Body of the mail.I want to get it as a different file( Attachment file). Please help

this my code

MailMessage Mail = new MailMessage(mFromEmailAddress,mToEmailAddress,mEmailSubject, mEmailBody);
Mail.Attachments.Add(new Attachment(mFileContent, mFileName));
mSmtp.Send(Mail);


Parvez mohamed








Answer this question

Attachment problem

  • Joe InfoSec

    Gmail to gmail -> the link doesn't show

    gmail to hotmail -> the link doesn't show

    gmail to outlook -> the link is there:

    outlook to gmail -> the link is there

    We are sending the link, some clients will display it properly, and some won't but we don't have control over the display.

    Mariya


  • Ehab H.GEDDAWY

    Thanks for all your response Maria and Durgaprasad........

     In the Overload I cahnged the Mediatype as given below........
    Mail.Attachments.Add(new Attachment(mFileContent, mFileName, MediaTypeNames.Application.Octet));



    I tried this in Hotmail as my Target its working again in gmail it fails again ...
    I want to do more test and I will Update the result.I want the solution as fast



  • chacke

    You got me confused here. Can you please clarify

    1. What overload of the Attachment constructor are you using:
    Attachment(Stream, ContentType) or other Which one exactly I have tried with 3 different overload, the problem is the same and it is that gmail / hotmail will treat the attachment as text and display it instead of showing it as an attachment link on which you can click.

    2. What do you mean by "i am sending the file as the I/O.Stream and the file name" A code snippet might be helpful.

    Thanks

    Mariya


  • Darko01

    This is not something that we can control from the client side. It appears the web-based clients are taking the attachment and displaying the contents inline which the desktop-based apps treat the file as you want. It appears the mail reader is the culprit here.

  • nmasao

    I don't quite understand
    What exactly do you mean by "as a different file"
    Please explain



  • Jaime Stuardo

    I am sorry that particular statement has confused you. It is as an attachment. When I open this mail in a web based mail like gmail, hotmail etc the content of the html file is displayed.Which I dont want it to happen.I want the file to be embedded and downloaded as attachment. If this mail is opened using MS Outlook it comes as an attachment file itself.

    I hope you understood my problem.

    Parvez Mohamed



  • Jijo P Baby

    Thank you for the reply.....

    let me clarify one more thing

    My application( email sending ) -> outlook -- you get the link
    My application -> Hotmail,Gmail --- you dont get the link.

    I have a doubt but I have not worked on it......Is it because i am sending the file as the I/O.Stream and the file name.......( I am doing this ,because i want to generate the file as a text and give custom name and send it to diffrent file).

    This is the exact problem that i am facing.


    with Regards
    Parvez Mohamed


  • Katee

    I personaly cannot agree with this. It is because I am receiving html attachments daily from my broker( Stock Broker).This is working perfectly. So there has to some thing that I have to do on this>>>>>>>>

    Parvez Mohamed



  • The Eagle

    Tried using gmail as the relay server.

    When I send from gmail to outlook - it works fine and I see the attachment as I am supposed to. When I send from gmail to itself - then the attachment shows as text. This means there is a bug in gmail for not being able to properly show the attachment

    Thanks

    Mariya


  • C#

    Thank you very much for the response. But I am still not ready to accept this as a bug in Gmail. I tried to send it in hotmail. The same result.It opens the content of the html file not as an attachment file. Please go through by testing it in Homail. I am saying that i cannot use in web based email Id's as a general.

    Waiting for a speedy response.

    Thanking you

    Parvez Mohamed


  • Justin Lee

    What are the values of mFileContent and mFileName here:

    new Attachment(mFileContent, mFileName)

    I am using

    new Attachment("MyFileName.html", MediaTypeNames.Text.Html);

    The attachment shows properly when I read it from the web using exchange. I'll try with gmail and let you know but I agree with Mike that you don't have control from the client side on the way your mail shows. One thing you may want to try is save one of the attachments from your broker and then try to send the exact same file with your code and see how that shows.

    Mariya


  • NetJaqua

    I/O.Stream is same as Stream.....I gave it to have more clarity....

    Even I tried all three Overloads that accepts Stream
    I Use ( Stream,String(for file name),ContentType).

    Now what I want is a solution to this.I need the link for the attachments. I cannot insist to the clients that uses the application not to have web based email ID.

    Thank you for your response... Awaiting further assistence

    Parvez Mohamed


  • Attachment problem