ewsExchangeAPI Send Email Performance Issue - exchangewebservices

We planned to migrate the Old Outlook MAPI Logic to EWS Exchange API to send email. I have tested the performance of sending email by triggering 1500 emails (looped) with the attachment of 256 kb PDF File.
For One email it is taking 5 to 6 seconds and overall it is taking 2 hours to send all 1500 emails.
But in other side using Outlook MAPI just taking 45 Minutes to send all 1500 emails.
Am just using basic send email method not much logic added as like below (not an actual code I used).
//Create the email message.
EmailMessage message = new EmailMessage(service);
message.Subject = "Message with Attachments";
message.Body = "This message contains one item attachment.";
message.ToRecipients.Add(UserData.EmailAddress);
//Create another item and use it as an attachment.
ItemAttachment<EmailMessage> itemAttachment1 = message.Attachments.AddItemAttachment<EmailMessage>();
itemAttachment1.Name = "Attached Message Item";
itemAttachment1.Item.Subject = "Message Item Subject";
itemAttachment1.Item.Body = "Message Item Body";
itemAttachment1.Item.ToRecipients.Add(UserData.EmailAddress);
message.SendAndSaveCopy();
Is this the API performance or I need to do some logic to send the email even faster.. Please suggest..
Thanks,
Gunasekaran Sambandhan

Sorry All,
There was a problem in my code. I just modified the way of call from consuming application, as well as a slight change in my .NET COM INTERFACE LIBRARY.
In my case VB 6.0 is the consuming Application.
.NET COM INTERFACE LIBRARY
I just modified the class representation in a way that:
Create Exchange Web service instance method
Send email
From VB 6.0 Application:
Call The Create Exchange Web service instance method
loop thru 1500 emails & call Send email with details
Just a basic discipline that has to be followed but I didn't so I got performance issue. Now I rectified myself & now it is working better that Outlook MAPI. (i.e. Now EWS Only takes 15 minutes)
Thanks,
Gunasekaran Sambandhan

Related

Send automatic emails from CSV attachment

Each day I receive an email with a CSV/excel attachment With a list of email addresses. I’d like to automatically take these addresses and mail an email template to all of them. The catch is, it has to be done on a work computer so I can’t download any additional programs to help with it. This will need to be done with native Windows apps. I’ve tried using VBA without success (I’m not well versed). Any help would be appreciated.
You can develop a VBA macro or COM add-in if you are going to distribute the solution to multiple machines. Basically, you need to handle the NewMailEx event of the Application class. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem. The EntryIDsCollection string contains the Entry ID that corresponds to that item. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item.
Private Sub Applicaition_NewMailEx(ByVal EntryIDCollection As String)
Dim mai As Object
Set mai = Application.Session.GetItemFromID(strEntryId)
MsgBox mai.Subject
End Sub
In the event handler, you need to save the attached Excel file to the hard drive. Then you can automate Excel to open the file and read its content for creating a new item based on a template saved. Read more about these actions in the following articles:
How To: Create a new Outlook message based on a template
How To: Create and send an Outlook message programmatically
How To: Fill TO,CC and BCC fields in Outlook programmatically

Odoo/OpenERP - send all mails from same adress

We have set up Odoo 8 as a multi-user helpdesk tool, which creates a new project issue for each incoming mail. Incoming and outgoing servers are configured correctly and system parameters are set to
mail.catchall.domain: company.tld
mail.catchall.alias: helpdesk
mail.bounce.alias: bounce
The problem now is that every time a user comments the mail thread to answer the original issue creator, a new mail is generated with header
FROM: [user]#company.tld
TO: [followers]
REPLY-TO: helpdesk#company.tld
Which is totally fine but leads to a sending failure due to our SMTP configuration. To get around this we want to achieve that all outgoing E-Mails are sent from the same specified address, like helpdesk#company.tld, no matter which user response to the thread.
How do we achieve this?
I had specific issue when I was working on Odoo 8 and I found fix but its not recommended action from developer view, because changing odoo source code is not recommended and changes can be lost.
So what I did was to change email from address to real email from address. Yes it's weird but that's how Odoo works. Odoo is always sending from one specific email address and changes email from to user email address, but if you will look at email carefully you will notice that real sender is always same.
The fix is changing this line
smtp_from = message['Return-Path']
to this line
smtp_from = tools.config.get('email_from')
in openerp/addons/base/ir/ir_mail_server.py file.
PS I don't like this solution.

How to setup an SMS alert to website owner when a customer fills in a form?

Been doing some research on how to setup an SMS alert straight to the website owner's (our customer) phone when a website visitor fills in a form on his website. Obviously we're happy to sign up to a provider and pay a few cents for each message - not expecting this to be a freebie service.
A lot of the google results you get for this deal with bulk texting out to the many recipients which isn't what we're looking at here.
So what's the simplest small-scale way to achieve this via HTML and simple scripting?
This daniweb forum post offers clear and simple instructions using Coldfusion and that's fine but as it's 7 years old we wonder if things have moved on and are there better suggestions?
We'd be happy to script it very simply through ASP.NET or PHP or something else, but hoping to keep it lightweight, since this is a very simple website belonging to a small business.
I am working on a similar thing for my company.
We use a GSM modem such as: ZTE MF668A
It is a USB adapter which you can insert a SIM card into.
We purchased an SMS only plan, which is like $15 a month and you can send unlimited SMS. However the set up might be a bit more complicated than just using a bulk SMS service.
You can set up Diafaan SMS Server (http://www.diafaan.com/) on the computer with the GSM Modem to accept emails for a particular domain. (e.g. ours is #sms.com). Our exchange server forwards email to the Diafan Server. Diafaan will take the email and convert it to an SMS and send it using the GSM modem.
In you php code, you can use PHPMailer (http://phpmailer.worxware.com/) to construct an email and set the mail to address to be #sms.com.
You use it something like this:
ini_set("sendmail_from","user#company.com");
ini_set("SMTP","smtp.company.com");
require("PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "smtp.company.com"; // specify main and backup server
$mail->SMTPAuth = false; // turn on SMTP authentication
//$mail->Username = "name"; // SMTP username
//$mail->Password = "password"; // SMTP password
$mail->From = "user#company.com";
$mail->FromName = $salesPerson;
$mail->AddAddress("user2#company.com", "Pricing");
$mail->AddReplyTo("user#company.com", "User2");
$mail->AddBcc($salesPersonEmail, $salesPerson);
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = $subject;
$mail->Body = $body;
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
There are also companies that offer SMS services such as PCSMS where you get 100 SMS per month for a fee. Then you just construct an email and send it to #pcsms.com.au. This is probably the easiest way to do it and is the way we used to do it, but the way we do it now is much cheaper.
Disclaimer, I do developer evangelism part time at Nexmo.
While you can setup a GSM modem to send SMS messages, it's likely easier (and depending on your usage, cheaper) to use a SMS API. Here are a few providers - pricing is in cents per message (depends on the API and destination, but hovers around a cent or two). You may be required to provision a virtual number - pricing there is generally dollars/month (again, depends on API and destination, hovers around a dollar or two).
Nexmo
Twilio
Tropo
If you're sending internationally, I think your best would be Nexmo. Or if you see any need to accept incoming messages in the future, Nexmo's pricing model will help you there.
All three APIs are straight forward REST/HTTP APIs - as long as whatever language you're using server side can make a web request, you should be able to send an SMS.
Eventually we used Esendex. Good support from them, decent code samples and plenty of mileage in the free trial (which in fact they were happy to extend when we asked).

EWS Body of Email coming back empty?

We are in the process of converting a batch job that processes our bounced emails that we send. We are switching from Redemption to EWS (just upgraded to Exchange 2010 from Exchange 2003). As you know bounced emails come in different forms. I have been able to work through all the test case emails i've got except for the ones that come in the form of:
Your message did not reach some or all of the intended recipients.
Subject: Hello
Sent: 4/01/2012 8:16 AM
The following recipient(s) cannot be reached:
hi#foo.com on 4/01/2012 8:19 AM
The e-mail system was unable to deliver the message, but did not report a specific reason. Check the address and try again. If it still fails, contact your system administrator.
smtp.mydomain.com #5.0.0 smtp; 5.3.0 - Other mail system problem 554-"delivery error: dd This user doesn't have a foo.com account (hi#foo.com) [-5] - mail.foo.com" (delivery attempts: 0)>
This is what is displayed in outlook. When i read the email with EWS the Body is empty. I need to look at the information above when i get the email with EWS. The emails have an attachment (which is the original email) though it doesn't look that way in outlook. I've tried to look at almost all the properties that comes back from EWS and have yet been able to find the text above. Redemption allow you to look at this info using ReportText. What we are specifically looking for is the email error delivery code. We do different things based on this code.
Edit: To be clearer the Body Property on my other test cases isn't empty. I'm loading the emails like:
Dim emailPset = New PropertySet(BasePropertySet.FirstClassProperties)
emailPset.RequestedBodyType = BodyType.Text
Dim f = EmailMessage.Bind(email.Service, email.Id, emailPset)
Update1: After some research it looks like i need to be able to read the Recipients table of the message in the PR_NDR_STATUS_CODE & PR_REPORT_TEXT fields. Still searching if there is a way to do this in EWS.
We were able to get enough info the
smtp.mydomain.com #5.0.0 smtp; 5.3.0 - Other mail system problem 554-"delivery error: dd This user doesn't have a foo.com account (hi#foo.com) [-5] - mail.foo.com" (delivery attempts: 0)>
part which is what we needed by telling the object to load the MIME content.
Definitely not the most straight forward API to use but hopefully we don't hit any more hickups.

Send mail with SMTP adapter with retry, retryinterval and delivery notification

I have an orchestration that receives an XML with some email properties(like: to, from, cc, subject, etc..).
Then I want to send the emailmessage with a dynamic port (and I assigned some of the values according the input xml). After the email has been sent, I want to do some further processing but that processing may only execute when the mail has been delivered succesfully on the SMTP server.
In the functional design they want to have a retry per hour and maximum of one day, after that periode a message must be in the EventLog when it cannot be delivered successfully.
Therefore I set the dynamic port with the context properties BTS.RetryCount to 23 and BTS.RetryInterval to 60.
I have set the dynamic SMTP port delivery notification to "Transmitted" and I have a catch exception block to catch the DeliveryFailureException.
Is this enough ?
It is a litte bit confusing for me reading several blogs if I should mark the scope Synchronized...
Patrick,
You're right, the documentation on this aspect of BizTalk delivery notification is scarce and confusing. After extensive testing, I have not been able to identify a difference wether the Scope is set to Synchronized = true; or not.
The official documentation for the Synchronized setting only applies to shared variables when used in both branches of a Parallel execution.
As for the Delivery Notification itself, I'm currently facing a problem in production where the FILE adapter produces its ACK event before the entire contents of the file is written to the output folder - it renders this part of the solutiong useless!