SharePoint 2010 send WorkFlow email on form submit/save click - email

Could you please help me understand how to send a workflow email, when user submits a task form. The process is to automate the sending of email to "BI Owners", when user fills out a form and once he/she clicks "save"/"submit", then the email should be sent out.
Thanks in advance.

Do you need to understand the Worfklow's configuration?
In that case, check this out:
Send e-mail in a workflow
How do you build up your form? It is an aspx, a webpart, some kind of magic?
Well, this is important, 'cause you have different ways to fire up your workflow, depending on that.
If you have all the form's control, well, this is my sending emails class:
protected void sendEmail()
{
try
{
string mailTo = dudeToSendMail;
MailMessage message = new MailMessage();
message.From = new MailAddress(mailSender);
message.To.Add(new MailAddress(mailTo));
message.Subject = mailSubject;
message.Body = buildMail(); // hey, dude, build up your mail here!
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Send(message);
}
catch (System.Exception)
{
throw;
}
}
Hope it helps.

Related

Email Sending .NET Core

I just want to have a function, which will be sending mail to different people.
I have written a Email Service, just like this:
public void SendEMail(EMail mail)
{
var body = JObject.FromObject(settings);
body.Merge(JObject.FromObject(mail));
GlobalTelemetry.TrackDependency("E-Mail Service", "Send", () =>
{
var result = AsyncHelper.RunSync(() => httpClient.PostAsync(azureFunctionUrl,
new StringContent(body.ToString(), Encoding.UTF8, "application/json")));
if (!result.IsSuccessStatusCode)
{
throw new InvalidOperationException(
$"E-Mail Service failed to send mails. Http Status {result.StatusCode}. Please check if the Url '{azureFunctionUrl}' is correct. Env: {Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}");
}
});
}
and by every other functions, which want to use this mail service, do just like this:
SendMail = mail =>
{
var fireAndForgetTask = Task.Run(() =>
{
try
{
eMailService.SendEMail(mail);
}
catch (Exception e)
{
Log.Fatal(e, $"Fail to send E-Mail to: '{mail.To}'");
}
});
};
it does work, but fireAndForgetTask is not used, I have no idea how to do it better.
Is it necessary to write a Email Job???
Some better suggestion is welcome :-)
I had a similar issue in my app for sending a password reset email, I did not want the delay of waiting for the email to send because if a hacker is trying to find out if an account exists for an email address the delay could indicate that the account does exist. So I wanted to fire and forget the email with no delay.
So I implemented a simple extension method named forget like this in a separate static class based on this so question:
public static void Forget(this Task task)
{
}
and then I send my email async and use that .Forget extension to not wait for it like this:
emailSender.SendPasswordResetEmailAsync(
Site,
model.Email,
sr["Reset Password"],
resetUrl).Forget();
note that I am not using "await" when I call this async method and the .Forget gets rid of the warning that would otherwise appear in Visual Studio when calling an async method without the await keyword

How to insert data in to database when mail comes in inbox(mail server)

I have a requirement. I have a mail server where user sends mail with there requirement and i need to insert data in my database when mail arrive in mail box. i Have no idea about it. If anybody has any idea please share. Thanks in advance.
Please find the below codes for sending and receiving mails accordingly:
Send Mail
var message = new MailMessage("admin#bendytree.com", "someone#example.com");
message.Subject = "What Up, Dog?";
message.Body = "Why you gotta be all up in my grill?";`enter code here`
SmtpClient mailer = new SmtpClient("smtp.gmail.com", 587);
mailer.Credentials = new NetworkCredential("admin#bendytree.com","YourPasswordHere");
mailer.EnableSsl = true;
mailer.Send(message);
Recieving Mail
client.Connect("pop.gmail.com", 995, true);
client.Authenticate("admin#bendytree.com", "YourPasswordHere");
var count = client.GetMessageCount();
Message message = client.GetMessage(count);
Console.WriteLine(message.Headers.Subject);
You can use this message object for database insertion.

AE.net.Mail, How to move mail to a new folder in outlook

How to move mail to a new folder in outlook?
My code:
using (ImapClient ic = new ImapClient(
imapAddr,
myEmailID,
myPasswd,
ImapClient.AuthMethods.Login,
portNo,
secureConn))
{
ic.SelectMailbox("INBOX");
bool headersOnly = false;
Lazy<MailMessage>[] messages = ic.SearchMessages(SearchCondition.Unseen(), headersOnly);
foreach (Lazy<MailMessage> message in messages)
{
MailMessage m = message.Value;
}
}
I try Google it but I can not find it .
Any suggestions are highly appreciated.
to move a message to another folder do this:
ic.MoveMessage(message.Uid, "some existing folder");
The uid is the unique identifiier for the mailmessage. I assume it maps to the message-id as described in RFC for Internet Message Format. Or otherwise to the UNIQUEID in the IMAP protocol.
to create a new folder use the this method:
ic.CreateMailbox("new mailbox name");
To send emails use an SmtpClient, like the one that is supplied in the .net framework:
using(SmtpClient client = new SmtpClient("your smtp server.com"))
{
client.Send("from#example.com",
"to#example.com",
"subject",
"Hello World");
}

create invoice and email in Magento

I want to automate the creation of invoice and email in Magento. Invoice creation seems to work but I am having getting the email part working...
Mage::app();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderid);
try
{
if(!$order->canInvoice()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
}
$invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
if (!$invoice->getTotalQty()) {
Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
}
$invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
$invoice->register();
$transactionSave = Mage::getModel('core/resource_transaction')
->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
}
catch (Mage_Core_Exception $e) {
}
}
I know my reaction is kinda late but for others who find this page:
You need to add the code for sending the email.
Do this after the register line:
$invoice->register();
$invoice->getOrder()->setCustomerNoteNotify(true);
$invoice->getOrder()->setIsInProcess(true);
$invoice->sendEmail();
setCustomerNoteNotify is used to say if the customer has to get the email.
setIsInProcess will change the order state to processing

How do you send an e-mail from Windows Phone 7?

What's the function for sending e-mails from WP7? I'm trying to set up a button to send feedback e-mail, but I can't find the right function.
Thanks,
Zain
Found it. You need to use the EmailComposeTask class. Here's a sample:
using Microsoft.Phone.Tasks;
...
void SendEmail(){
EmailComposeTask email = new EmailComposeTask();
email.To = "receiver#stuff.com";
email.Subject = "hey";
email.Body = "Wazaaaaaaaaaaap! How you doin?";
email.Show();
}