[Worflow vs 2005] Problem with sendemail.
-
Tuesday, March 20, 2007 1:02 PM
Hi,
i have just created a simple worflow to send a email to the administrator whenever a new element is added in a particular list.
so in the sharepoint sequential workflow diagram, i have just added a sendemail element after onworkflowactivated1 element.
then i went to the properties of the sendemail element i gave a name to the correlationtoken and specified for the owneractivity : workflow1.
i checked my outgoing and in going email setting and everything is definitly right.
My deployement is aswel perfect, i have actived the feature and then have associated the worflow to a list and the workflow fires whenever a new element is added.
However when i add a new element to that list, the workflow statut in the list is a error occured.
I dont know what may cause this. that is probably something to do with my programming .
so i have joined a piece of my code.
public sealed partial class Workflow1: SharePointSequentialWorkflowActivity{
public Workflow1(){
InitializeComponent();
}
public Guid workflowId = default(System.Guid); public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties(); public String sendEmail1_From1 = default(System.String); public System.Collections.Specialized.StringDictionary sendEmail1_Headers1 = new System.Collections.Specialized.StringDictionary(); public String sendEmail1_Subject1 = default(System.String); public String sendEmail1_To1 = default(System.String); private void sendEmail1_MethodInvoking(object sender, EventArgs e){
sendEmail1_From1 =
"arioule@yahoo.fr";sendEmail1_To1 =
"admin@acb.co.uk";sendEmail1_Subject1 =
"salut";}
}
thanks for your help.
All Replies
-
Monday, June 25, 2007 10:13 AM
Hi Arioule
I had the same error on my sharepoint list when starting a workflow instance.
Error Occured
I got this error fixed by making sure that the CodeBesideAssembly property value in my workflow.xml file matches with my workflow dll's version and the public token. I used the .NET reflector to check all these.
After fixing the error occured error, I got this error for my sendEmail activity
I couldn't get my sendEmail activity to send emails and my code looks exactly the same as yours, what I get is this error message The e-mail message cannot be sent. Make sure the outgoing e-mail settings for the server are configured correctly.
Well I have set all the outgoing emila settings that I know exits in Central Admin but the error is still there.
Any clue/idea on this is so much welcome...
Remandlo
-
Friday, July 20, 2007 9:51 AM
hi,
i am also facing the same issue..but it is not very consistent. this error comes everytime but at times it sends mail but not always. Can you tell me if you found any solution??
-
Tuesday, July 24, 2007 1:18 PM
Hi,
I have reproduced the issue when nesting the SendEmail activity in several activities:
e.g. ParallelActivity - While - Sequence activity - IFElse branch - IF Else Branch
However, SendEmail works fine when it is not nested deeply.
It seems nesting the SendEmail activity is causing the problem.
Has anyone one found a resolution/workaround? Please advise urgently as I'll need to demo a VS.2005 workflow and we are currently evaluating sharepoint v/s documentum.
I have built a list of sharepoint issues & resolutions and can share it.
Cheers
Kavish
Email: kavish18@hotmail.com
-
Wednesday, August 15, 2007 4:59 AM
Has anyone found a resolution for this yet?
I'm having the same issue.
-
Thursday, August 16, 2007 7:10 AM
Hi,
As I understood you are defining a colleration token for each email activity, and i think this might be the error becuase the email activity should take the colleration Token of the Workflow (the one which you should have created for the OnWorkflowActivated activity).
If that also didnot work please post the error reported in logging file of the sharepoint
Best Regards
-
Wednesday, September 26, 2007 7:47 AM
Hi everybody,
i did some research and it seems to be really in that way:
if
you use the SendEmail activity in a state machine wf
(which is always nested in another EventDriven acitvity)
Then
there is no way to set the parameters like .To, .Subject,
.Body and so on programmatically.
A method you attach in SendEmail at MethodInvoking
gets executed, yes, and you can see that the properties
like .To changes, but they dont get uses.
Even if you try to put a Code Activity before or after the
SendEmail activity, which sets this eMail-Properties,
they change, but dont get uses. Only the values you
put into the Properties-Window at design time are used.
After initialization it seems that the values are kind ofsealed, and the set property methods inside are not
update the real internal value which gets used at
execution time. But only if activity is nested ... weird ..
I cant believe the Sharepoint workflow activities developers
never tested a SendEmail acitivity in a state machine wf,
and tried to set parameter via code ....
Bye
Roland
-
Wednesday, September 26, 2007 2:42 PMI too am having this problem, but I fixed it. I don't know why it works this way, but I have it working and that is all it matters too me.

What I was trying to do was set the email body using code. It would not work with this code:
Code Snippetprivate void OnSendManagerApprovalEmail(object sender, EventArgs e)
{
sendManagerApprovalEmail.Body = "Your manager has approved the Status Change Request. You can view the orginal request here: " + this.workflowProperties.ListUrl;
}
So what I did was create a custom field, but clicking the ... box in the Body box in the email activities properties and creating a custom field for the body. I then set the custom field to the text I want.
Code Snippetpublic String sendManagerApprovalEmail_Body1 = default(System.String);
private void OnSendManagerApprovalEmail(object sender, EventArgs e)
{
sendManagerApprovalEmail_Body1 = "Your manager has approved the Status Change Request. You can view the orginal request here: " + this.workflowProperties.ListUrl;
}
I hope this helps someone else. You can also use this to set any of the properties programmatically.
Thanks,
Vincent
-
Thursday, September 27, 2007 8:58 PM
Hi Vincent,
this was a phantastic tip!
Thank you thousand times, cause
it saves me from a lot of pain ..
Bye and have a good time
Roland
-
Tuesday, October 09, 2007 6:53 AM
Hi.
I've read this article thoroughly and would like to admit that I've encountered one more problem concerning e-mail activity. I don't know the real issue but after creating a custom field for email body property and assigning it in e-mail activity properties I receive truncated e-mail body. There is no limitation in our Exchange server and other messages doing fine with it. I've also tried to vary body text but it seems like it has its own size limit mechanism which doesn't permit to habe body bigger than this mirracle value.
Did anyone face with this problem. Any suggestions are of much value.
Thank you! -
Wednesday, October 10, 2007 3:03 PMI just did a test with a string of words totalling 1,116 characters and had no problem. This is my development server so it doesn't use Exchange, but instead it uses the Windows POP3 service. I doubt that would make a difference.
-
Thursday, October 11, 2007 7:19 AM
2 vincentw56
Thank you. I think the root of evil is not in POP3 services whether they used as native Windows POP3 Services or Exchange POP3 services. I create body message with StringBuilder class object and fill with it the inner string member variable in private routines. So I use exactly the same technik as I've read here (unfortunately )))) I did it earlier than read here, thus reiventing the wheel))) ). As debugging had been folowing, I was convinced that the resulting string is not truncated. And this integrity is being preserved until the email activity fires. Next I see the truncated html e-mail message in my Outlook....like a mirracle.
Do you have any suggestions?
Thank you! -
Tuesday, October 16, 2007 2:09 PM
The problem of the truncated email (I believe) is probably because there are no line breaks ("\r\n" in c# or vbCrLf in VB) in your email. Since you are using a stringbuilder, I believe this can be handled by inserting linebreaks in there or doing some post-processing afterwards. I ran into the same problem, thought it was Outlook Express, but the problem disappeared when I started putting line breaks into my stringbuilder... then the problem disappeared.
Hope this helps,
Max
-
Tuesday, October 16, 2007 3:12 PM
MaxWeber wrote: The problem of the truncated email (I believe) is probably because there are no line breaks ("\r\n" in c# or vbCrLf in VB) in your email. Since you are using a stringbuilder, I believe this can be handled by inserting linebreaks in there or doing some post-processing afterwards. I ran into the same problem, thought it was Outlook Express, but the problem disappeared when I started putting line breaks into my stringbuilder... then the problem disappeared.
2 MaxWeber
Perfectly, friend! Thanks a lot!!!!!! -
Tuesday, November 06, 2007 9:52 PMJUST A BIG THANKS!!!!
-
Wednesday, December 05, 2007 5:28 PM
Buddy you are the best! Thanks! -
Friday, December 07, 2007 5:21 PMFor settings sendEMail properties at Method Invoking you must cast sender parameter as is:
Code Block(sender as SendEmail).To = "guest@nobody.com";
(sender as SendEmail).From = "fromemail@noobdy.com";
[..]
Same setttings for all activity in the workflow (especially for delayActivity)
Max -
Monday, December 10, 2007 9:59 AM
Hi Max,
this is also good to know!
So I learn more and more about Sharepoint + Workflow Foundation, now
I work with it since almost 2 month and still I find it not easy to handle.
For example:
I inserted a global private variable of type SPUser and SPListItem into my
workflow, and make more modification. Then I tested the workflow, and
it went to "finished" almost immediately after the start. After hours of
search i found in the Sharepoint Log I activated, that there is a problem
with dehydration of SP... objects (they are not serializable).
More and more I find the WWF for Sharepoint too complicated, the
learing path too long to get fast productive. Am I the only one?
-
Thursday, January 15, 2009 8:11 AM
hey andreas,
if you send mails via Sharepoint (SPutility.sendmail , etc) there is a limitation of 2048 caracters. You can try it yourself if you want to, At first I didn't believe it as well because the class is derived from the main mail class, but sharepoint somehow limits the number of caracters.
kind regards
andy -
Friday, July 16, 2010 10:02 AM
Thanks a lot,
You are my god. ;-)
-
Tuesday, December 20, 2011 4:39 PM
Hi Massimo,
Thanks for this. I was having the same problem. My Send email activity was nested in while activity and was not working.
This did the trick for me.
Thanks,
vicky

