Click here to Skip to main content
15,896,726 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am trying to pass a list to a method. The list is defined as
Private attachments As New List(Of System.Net.Mail.Attachment)...

The method declared in RemoteSMTP is
Public Function Send(ByVal mailTo As String, ByVal mailSubject As String, ByVal mailHTML As String, ByVal mailCC As String, ByVal mailBCC As String, ByVal attachments As List(Of System.Net.Mail.Attachment)) As String

...

End Function

VB
Private Function SendEmail() As Boolean


        Dim success As Boolean = True
        Dim remEmail As New RemoteObjects.RemoteSMTP

        Try

VB
remEmail .MailTo = "abc@gmail.com"
            remEmail .MailCC = ""
            remEmail .MailBCC = ""
            remEmail .MailSubject = Me.txtSubject.Text
            remEmail.Attachments = attachments
remEmail.Send()
End Try
Catch ex As Exception

            MsgBox("Exception caught trying to send: " & ex.Message)
            success = False
        Finally

remEmail =Nothing




But i get the error at remEmail.attachments = attachments "Type 'System.Net.Mail.Attachment' in Assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' is not marked as serializable."



Where am i going wrong?Please help.
Posted
Updated 21-Jun-13 10:14am
v6
Comments
José Amílcar Casimiro 21-Jun-13 15:51pm    
show us the code...
vidkaat 21-Jun-13 16:01pm    
Updated the question with code.
José Amílcar Casimiro 21-Jun-13 16:10pm    
RemoteObjects.RemoteSMTP what is this? Your updated code and your question does not match.
vidkaat 21-Jun-13 16:13pm    
it is just an instantiation.
José Amílcar Casimiro 21-Jun-13 16:15pm    
When you invoke the method send from that class instance you are getting an exception, so probably, the problem is with that object.

1 solution

Attchement mean a select a file .... .
make a opendialog for select a pp
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900