Email Automation from Outlook Express using JACOB.jar with Java - java

I have to automate emails from Outlook Express Client using Java. Below are the requirements:
Format the RichText Email using predefined template(Provided in Excel)
Send the email to dedicated Receiver Email Id
Send the reminder email by keeping the history of previous email
I was able to achieve all the mentioned requirements for Lotus Mail Email Client by using Notes.jar.
As I can not use JavaMail to directly send email to Email Server and Read due to Organization's Policy. So I have to go with automation from Email Client only.
I have heard about JACOB.jar. Can anyone please share if above all mentioned requirements be achieved with JACOB.jar? It would be really a great help.

Related

Can't set the email sender in JavaMail - Spring [duplicate]

I want to send an email from A to B, with HEADER and CONTENT through gmail.
How to do that by PHP?
I've specified the FROM (from#example.com), but when I receive the email, it's still from my gmail account (abc#gmail.com).
$mail->From = "from#example.com";
$mail->FromName = "Mailer";
$mail->AddAddress("abc12#163.example", "Josh Adams");// name is optional
$mail->AddReplyTo("abc12#qq.example", "Information");
How do I change the FROM part?
The short answer - you can't.
Google rewrites the From and Reply-To headers in messages you send via it's SMTP service to values which relate to your gmail account.
The SMTP feature of gmail isn't intended to be an open or relay service. If it allowed any values for the From header, it would significantly dilute Google's standing with spam services, as there would be no way to verify the credentials of the sender.
You need to consider alternatives. How are you planning to host your script/application/website when it's finished: virtually every hosting solutions (shared/vps/dedicated server) will come pre-configured with an email transfer solution: be it sendmail or postfix on *nix, or IIS on Windows.
If you are intent on using gmail then you could:
Setup a dedicated myapp#gmail.com account
If you own the domain you are supposedly sending from, use the free gmail for domains, and setup a myapp#mydomain.example account.
====
Edit June 2015
It was suggested that GMail does allow sending via different addresses. As far as I can tell, this is for sending via the GMail wep app, and utilises your existing external SMTP server, which is not relevant to the original question.
====
Edit Nov 2013
Seeing as this is still getting a trickle of votes. A quick update.
Google have withdrawn their free GMail for domains. There are plenty of other free services around. One of note is Mandrill - a one-to-one email service intended for transactional emails (e.g. ecommerce orders etc.). It's ran by MailChimp, who pretty much know all there is to know about sending email at volume. They also give you 12k/month free, which is rather nice.
This question and correct answer may be relevant:
When using Gmail for SMTP, can you set a different "from" address?
Gmail requires you to validate From addresses before sending mail as that email address. So you need to add a new sender in your personal gmail account and validate it.
Doing so will allow you to authenticate with youremail#gmail.com and send email from from#example.com
Unlike everyone else, I'll take the plunge and make the assumption that by letters you mean emails...
But I'm not sure what you are getting at when you mention that it should include "Headers and Content". Do you want to forward emails? Do you want the emails from A to appear as though they came from B's gmail account in the headers? Are you building some sort of gmail client?
The easiest way to send an email with PHP is with the mail function. This example comes straight from their documentation:
$to = 'nobody#example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster#example.com' . "\r\n" .
'Reply-To: webmaster#example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
If you want the headers to appear from A's gmail and not to simply change the from/reply to part, you'd have to use gmail as the SMTP server. I don't know if you can set that at the script level.
The answer above are not quite correct.
You are definitely able to specify any senders as long as you own the other email address.
As the help page explains:
On your computer, open Gmail.
In the top right, click Settings.
Click the Accounts and import or Accounts tab.
In the "Send mail as" section, click Add another email address.
Enter your name and the address you want to send from.
Click Next Step and then Send verification.
For school or work accounts, enter the SMTP server (for example, smtp.gmail.com or smtp.yourschool.edu) and the username and password on that account.
Click Add Account.
Once that email is added successfully,
you can send email on the behalf of the new email address in gmail.
Google will not rewrite your from email in this way while you're sending email via Google SMTP.
You need to go to GMAIL settings and add new alias.
You will be asked SMTP information, which is basically useless, since you are using SMTP to send email, BUT the catch is that if your alias is on Google Suite domain it will be added just with simple email confirmation!
Once you have the alias there, you can change "From" header in your SMTP email.
NOTE: You cannot change the "From" address to whatever#dude.example, that's just how Gmail works and is the reason it's trusted.
If the reason you want to use gmail is because you don't want to set up an MTA (the reason you stated in a comment to this answer), you have 2 options:
If the web server is at your
home/work place; use your ISP's
smtp-server
If the web server is at a dedicated
hosting center, ask them what
smtp-server to use.

Send/Receive Email from within Web Application?

I have an Order Management (Web) Application (in Java/Java EE).
The application users want to Send Receive email communication to Customers who placed the Order, from within the Web-Application. The Email Trail must be associated with the Order.
The use-case is:
User opens the Order Detail Page. Order info. is displayed.
On that page - Clicks on Email Icon, and it will show up all Email Communication (sent/received) for that Order till date.
For that Order - You can see new incoming mails, reply to mails or send out new mails to the Customer - all related to that Order.
Questions:
Sending out emails is easy, but how to receive emails within the app?
What is the email account here - A common Email Account called orders#myorg.com (and based on subject line/some-header emails are filtered etc.) or is it orderid#myorg.com (in which case new email acct creation is reqd per order) or ?
We already have Microsoft Exchange Server via which company email travels. Could we leverage that in someway or do we need to setup a new Mail Server?
Any ideas are welcome.
If you're willing to take on the dependency, Spring Integration can comfortably read email from a designated server on a polling (POP3, IMAP) or event-driven basis (IMAP-IDLE). [1 & 3]
[2] You can use a dedicate mail account and filter the mail sent to downstream channels based on the subject (or other field) of the incoming mail. The following snippet from the Spring site illustrates this:
<int-mail:imap-idle-channel-adapter id="customAdapter"
store-uri="imaps://some_google_address:${password}#imap.gmail.com/INBOX"
channel="receiveChannel"
should-mark-messages-as-read="true"
java-mail-properties="javaMailProperties"
mail-filter-expression="subject matches '(?i).*Spring Integration.*'"/>
Where mail-filter-expression filters the email that will be flushed down receiveChannel. For all interested parties (channels), you'll have one <int-mail:imap-idle-channel-adapter/> listening to your Exchange server.
While it's not cumbersome to use, I'd recommend you look at a short overview of EAI according to spring and of EAI in general
You need the following.
Java Mail API to programmatically send emails through some exchange server.
I would suggest to use a dedicated email server to receive application specific emails. You can do this by using James. You can send and receive emails through this software.
If you use your existing Microsoft Exchange Server, you can always use redirect to your application specific email server.
Receive emails
Here is example code to read an email Are there any good short code examples that simply read a new gmail message?
Email account here
For each user create an email account and have user's web app credentials used as credentials for email as well.
Use hashed order id as part of subject to relate each email chain to specific order.
Microsoft Exchange Server
Use either exJello is a JavaMail provider (http://www.exjello.org/)
OR Use JavaMail API with DavMail Gateway (http://davmail.sourceforge.net/)
From a user point of view I think keeping a specific subject is more difficult. I would suggest a sub domain like myapp.myorg.com or a new domain like myapp.com
Either ways have a catch all so that all mails go to a specific email like orders#myapp.myorg.com
Then your script can check the real TO. This might be more natural and 'cool' -> each order has its own mail id! On top of that use James or other mail software to get delivery to your code.

How to make reply of an email becomes a HttpRequestServlet to a web application?

I got a requirement which I don't know how to get started.
Requirement:
The application will send emails to clients (using org.springframework.mail.javamail.JavaMailSender) with same "from email address" as support#mydomain.com. Also the email content will have some hidden information such as client_id. If the client reply back to that email, I need to get that as an HttpServletRequest to a Servlet so that I can process it.
EDIT:
This web application does not have google app engine setup, but my requirement is matching similar to this link.
When someone replies to the mail you sent him that mail will go to the POP3 server configured for your domain. From this SMTP server you can read this mail using the Java Mail API. You can have a Spring timer task to keep polling this mailbox after every few seconds.
I would look at the below resources to see how to read mail from the POP3 server -
Using JavaMail API -
http://metoojava.wordpress.com/2010/03/21/java-code-to-receive-mail-using-javamailapi
Using Spring -
http://blog.solidcraft.eu/2011/04/read-emails-from-imap-with-spring.html
Better and popular solution is to have a link in your email and asking user to click it and asking specifically not to reply to this email (from address can be noreply#domain.com)
For getting a servlet call in an email reply, you need to use
http://javamail.kenai.com/nonav/javadocs/com/sun/mail/pop3/package-summary.html
Keep polling for new emails in your reply address(for eg support#domain.com) using POP, and when new email comes trigger a httprequest(HttpClient? ).
On a related note you can add user_id and similar stuff using a + in reply email address
For eg support#domain.com and support+uid_21_catid_32#domain.com will deliver to same address. Everything after + is ignored. But you will get this info in reply email event as to address and decide on who is the user.This could be a security concern for sure if not properly implemented.

Retrieving Email attachment from Outlook

I have a requirement, I am getting more bounced emails when i send some email newsletters to my clients and I am sending the email fron Outlook. Bounced email is coming from "Mail Delivery Subsystem" and it has some attachments. In that attachments, it is having my original mail. I want to extract that original email through java. I would like to know any feasible solution for this
Any help in this regard is much appreciated.
For Exchange Server 2007+, you could use Microsoft Java EWS API or just talk directly to EWS. See related SO post.
You would have to use .NET to integrate directly with Outlook via VSTO.

How to send an email to a java program

I'd like to write a program, probably a servlet or something to run on the a google app engine that I can send an email to. So not a program to send email, but one that can receieve it and parse it.
My question is, what code or API are out there that can receive an email?
Basically on your google app engine you can use an inbound mail service.
Please see this documentation for more information.
http://code.google.com/appengine/docs/java/mail/overview.html#Receiving_Mail_in_Java
You cant send an email to a program, you send an email to a server, so what you are looking for is a way to access an email server via your program. Unfortunately there is no single solution here, you need to configure your program for every different email account/server you want to access. (If you have ever set up an account in outlook or something like it you will get the idea)
For example here is a link to the gmail api, you could use this to access gmail accounts
http://code.google.com/apis/gmail/
You need to have a mailbox to send message there and you could read messages with the code like this: http://www.java2s.com/Code/Java/Network-Protocol/GetEmailMessageExample.htm
This can be done with a built in Java library.
javax.mail
Check out this link. It should be able to help you get started.
This won't work for every mail server, but depending on your setup it might help.
To send an email to a Java program, that program must be running. Generally that means a server style (aka service) receiver is favored.
For the email to be received, the Java service must understand an email protocol. There are a number of protocols, but SMTP is the standard for receiving email. Once you have a service that understands SMTP protocol for receiving email, you have written a mail server.
Note that most people don't care to write a mail server, as a mail client needs to connect to the server and pull the email to make it readable. Keep this in mind when designing the solution to your problem.

Categories

Resources