1

I was using the Send Email task but it has a limitation of 255 characters in To List/Recipient List. Then i switched to Script Task where in i am using:

MailMessage mail = new MailMessage();
mail.To.Add(Dts.Variables["Myvariable"].Value.ToString())

Now i am storing the list of mail ids separated by a comma in MyVariable But still it have a same limitation of sending email to the List which does not exceed in 255 Characters.

Does this is the case for both the options or i am missing something?

James Z
  • 12,209
  • 10
  • 24
  • 44
Ankit
  • 21
  • 1
  • 2
  • Is there an error occurring? What is it? – Chris Mack Aug 05 '17 at 13:18
  • It's only picking up only 255 characters in Email String which i have assigned to my variable. Is that also a limitation in Script task as well? – Ankit Aug 07 '17 at 07:53
  • Have you verified that the variable only contains 255 characters? What is actual the length of the value that is being written to the variable (or that you have stored in it)? You need to find out whether or not the variable contains more than 255 characters to begin with, and if so, at what point that changes. – Chris Mack Aug 07 '17 at 13:37
  • 1
    I have tried to assign a string which is more than 255 character in the variable and it automatically truncates the string to 255 character while sending the mail and i came to know when it truncated the last email id due to this 255 character limitation and the package failed due to incorrect email id – Ankit Aug 08 '17 at 14:17
  • Just so I'm clear, if you place `MessageBox.Show(variableValue.Length.ToString());` (where `variableValue` is your email string) in your Script Task, does it truncate to 255 characters? – Chris Mack Aug 08 '17 at 14:39
  • Yes i tried MessageBox.Show(variableValue.Length.ToString()). It shows me truncated string – Ankit Aug 09 '17 at 11:50
  • Yes i tried MessageBox.Show(variableValue.Length.ToString()). It shows me truncated string and length as 255 only – Ankit Aug 09 '17 at 11:56
  • This means that your string is truncated before the email task, so it's nothing to do with that. How are you getting the string into the variable? – Chris Mack Aug 09 '17 at 12:00
  • Yes you are right. Somehwre in the SSIS package the value was being assigned to a variable with varchar(255). So instead of making that variable varchar(max) because then i have to change the variable type to Object and then again cast this variable from Object to String in Script task what i have done now is i have made this variable as varchar(8000).Thanks for your help because i was able to resolve this only after you told me to check the length in messageBox.Show().Thank you Chris – Ankit Aug 09 '17 at 13:13

1 Answers1

0

I just found a solution to this after @Chris Mack told me to debug it with help of Messagebox.Show()

So if you are using a Script task then you don't have this 255 character limitation to send the mail. The problem with my SSIS package was that the Script task was using a variable to send mail to the recipients and the value to this variable was assigned somewhere inside the package and the variable was defined as varchar(255). So i just changed it to Varchar(8000) and it worked ( but if i would have used varchar(max) instead of varchar(8000) then i have to change the variable type to OBJECT Type which i did not want to do.)

Ankit
  • 21
  • 1
  • 2