+ Start a Discussion
Ketan Solanki29Ketan Solanki29 

View state error while sending email with attachment

Hi all,

 

I have one Visual Force page to send email with attachment. this page display the list of Transactions( custom object with 10 to 12 columns) i can select 1 to 200 Transaction on this page and by clicking the  "send" button , email is send to the Owner of that's transactions Master Account owner email address. i have also one section on this page to use attachment with this email.while i am sending email with 4.2 MB files and selecting 100 transaction i get error like the bellow screen.

 

Maximum view state size limit (135KB) exceeded.Actual view state size for this page was 157.031KB.

 

If i am attaching file with less then 1 MB, it will send email successfully.

 

My question is that is attachment file is also calculated on view state of that page. if not that what is the reason behind this error.

 

Please, help me on this.

 

colemabcolemab

Your attachment will be part of the view state unless it is marked transient.

 

Another option is to use a try, catch, and finally block and then in the finally block set the attachment to a new / blank attachment.

 

Of course in the try block you would try to insert the file.