Symptoms
Email Event in Workflow fails due to new line in the subject field.
Diagnoses
I have an email event in a workflow ,the subject of the email is a data field.
If the data field of the subject has a line break, the workflow goes in error mode , raising this error message"The specified string is not in the form required for a subject.".
Resolution
Use Inline function:
URL Decode(Replace(URL Encode(Datafield),
, EmptyString)
Or you can use Stored Procedure to remove new lines from string:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE RemoveNewLinesFromEmailSubject
@EmailSubject as nvarchar(max) = ''
AS
BEGIN
SET NOCOUNT ON
SELECT REPLACE(REPLACE(@EmailSubject, CHAR(13), ''), CHAR(10), '')
END
GO