We help IT Professionals succeed at work.

Adding an Attachment from an ASP.Net page with VB.Net

JB4375
JB4375 asked
on
Medium Priority
375 Views
Last Modified: 2012-08-24
I have a page that allows a user to submit a ticket to our Help Desk ticketing system Remedy.

For some issues and requests the amount of information required is rather complex. The solution has been to generate a formatted RTF file that contains all of the information submitted.

In testing I've been able to create the file and save it to my hard drive, but for this particular page it wouldn't be acceptable to have the user click an attach button and then browse to the file.  

I really want to be able to save it in the memory space of the page itself, specify the name of the attachment and have it sent on submit.

Could someone direct me to an example?

Thanks in advance,

JB
Comment
Watch Question

Commented:
Are you using ASP.Net MVC with C# or VB?  

This article should help you send attachments if that's what you're asking http://www.codeproject.com/Articles/10828/Sending-Email-with-attachment-in-ASP-NET-using-SMT

I recommend using google's outgoing smtp server for improved reception.

Author

Commented:
VB. Thanks for the link. I'll check it out.

JB
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2014
Commented:
>In testing I've been able to create the file and save it to my hard drive

Is that on the server's harddrive?

>it wouldn't be acceptable to have the user click an attach button and then browse to the file.

If its on server, user has nothing to do with it. You can attach it directly.

Author

Commented:
Thanks Guys,

I was able to do it directly with the following:

Imports System.Net
Imports System.Net.Mail

    Public Sub Send_Email()
        Dim Mail As New MailMessage()
        Dim mailBody As String

        Dim attachment As System.Net.Mail.Attachment
        Attachment = New System.Net.Mail.Attachment("filename")
        Mail.Attachments.Add(attachment)

    (Standard here....   Mail To, From, Mailbody etc. )

End Sub

Explore More ContentExplore courses, solutions, and other research materials related to this topic.