Jump to content

OpenFileDialog details?


zezu10

Recommended Posts

I am currently trying to design a form which will allow my users to email details to a web daemon, but I am wanting to also allow them to send attachments on this form. Having never done this I searched around and found an example which is asking me to do the following;Change OpenFileDialog Name OFDDefaultExt *.*InitialDirectory c:\Multiselect TrueHow abouts do I go about this? My form for the attachments contains a listbox and two buttons (add attachment, remove attachment)any help would be very much appreciated.

Link to comment
Share on other sites

the email sends but the attachment does not work...

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click		Dim Counter As Integer		Dim sName As String		Dim sLastName As String		Dim sLocation As String		Dim sTelephone As String		Dim sSystem As String		Dim sDept As String		Dim objAttach As MailAttachment		Dim postedFile = txtAttachment.PostedFile		Dim strPath As String = ""		Try			strPath = Path.GetFullPath(postedFile.FileName)		Catch		End Try		sName = Trim(txtFirstName.Text)		sLastName = Trim(txtLastName.Text)		sDept = Trim(txtDept.Text)		sLocation = Trim(ddlBranches.SelectedValue)		sTelephone = Trim(txtTelephone.Text)		'Set the properties		'Assign the SMTP server		obj.SmtpServer = txtSMTPServer.Text		'Multiple recepients can be specified using; as the delimeter		'Address of the recipient		Mailmsg.To = txtTo.Text		'Your From Address		'You can also use a custom header Reply-To for a different replyto address		Mailmsg.From = "\" & txtFromDisplayName.Text & "\ <" & txtFrom.Text & ">"		'Specify the body format		If chkFormat.Checked = True Then			Mailmsg.BodyFormat = MailFormat.Html 'Send the mail in HTML Format		Else			Mailmsg.BodyFormat = MailFormat.Text		End If		''Attach the files one by one		'For Counter = 0 To lstAttachment.Items.Count - 1		'	Attachment = New MailAttachment(lstAttachment.Items(Counter))		'	'Add it to the mail message		'	Mailmsg.Attachments.Add(Attachment)		'Next		Try			objAttach = New MailAttachment(strPath)			Mailmsg.Attachments.Add(objAttach)		Catch		End Try		'Mail Subject		Mailmsg.Subject = txtSubject.Text		'Mail Body		Mailmsg.Body = "<br>[Client First Name] " + sName + "		'Call the send method to send the mail		obj.Send(Mailmsg)	End Sub

Link to comment
Share on other sites

I think the problem may be here:

strPath = Path.GetFullPath(postedFile.FileName)

The mail message is being sent from the server. I believe, at this point, the file (postedFile) only exists on the server in memory as a memory stream rather than an actual file in the filesystem. You may have to save this file to a temporary location before you can attach it to your message.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...