How to download refrences part of emails using java? - java

I am trying to download the email using imap java ..I have downloaded most of the part of email but don't know how to download references part of email?Can someone provide help about which function is used to do that?any links to some page would be helpful.Thanks
References: <CALdDwZ=PQDu2eS1R2ONsrHJDgHDeZuNCUfEsfRqC3efzZfMaqg#mail.gmail.com>
<CAAD0KRhD7w1qdRiTG6U00ShroE1R00h7F73_AQ4yRnDE7jm6HA#mail.gmail.com>
<CALdDwZm2np83PmjrHY1jO54+6-dNKaM7+oxjaUHE_rUitMffrA#mail.gmail.com>
<CAAD0KRg2TJt0Y4oo-CsOCexrmat6kHakuFZSm_AvTDuSXjiTTw#mail.gmail.com>
<CAAD0KRhXUUwNjcAhc+4h-ftiJFW7q0y9gmDRGZ0khzyzWUDxbQ#mail.gmail.com>
<CAAD0KRgp6nhupkQhu2LWe6mXGuvK35XFdZLUUjfC4uGvsOZtcQ#mail.gmail.com>
<CAAD0KRhXaJ5FAuOxR760HBzgaD-_JyXoVAymeQf+nQdCawEgGA#mail.gmail.com>
These are message Id's of all the mails which took part in a conversation..Usually this is a part of an email.so I want to download it?

For downloading the References part of the email we need to use getHeader() function of Imap java ..This is the code :
if( msg.getHeader("References")!=null)
{
String[] headers = msg.getHeader("References");
System.out.println("headers");
for(int ab=0;ab<headers.length;ab++)
System.out.println(headers[ab]);
}

The references are Message-IDs. There's no way to directly access a message given the Message-ID. You can use the Folder.search method to search for messages with the given Message-ID in the specified folder, but there's no way to know what folder the message might have been moved to, nor is there any guarantee that the current user ever saw the referenced message.

Related

Programmatically set signatures in Outlook client using JAVA

I want to set signatures for multiple address in outlook client application. I read concepts using VBA and other scripts. But I want to do it in Java. I have already created the html signature files. I can use AD to pull user information but I don't know how to connect it with Outlook using Java. Can someone help me with this?
Thanks in advance.
Outlook Object Model does not expose signatures at all.
On the Outlook account level, the name of the signature is stored in the account profile data accessible through the IOlkAccountManager Extended MAPI interface. Since that interface is Extended MAPI, it can only be accessed using C++ or Delphi. You can see the interface and its data in OutlookSpy (I am its author) if you click the IOlkAccountManager button.:
If using Redemption is an option (I am also its author), you can use its RDOAccount object (accessible in any language, including Java). New message signature name is stored in the 0x0016001F property, reply signature is in 0x0017001F (can be read or set using RDOAccount.Fields[]).
You can also use the RDOAccount.ReplySignature and NewSignature properties.

Sending an outlook email from client computer running a program installed on the server

Good day to you all
I have a java web application running over a network and the application is installed on the server.As part of the the program it sends outlook emails automatically, I used java com bridge(jacob) to achieve that. The emails are being send on the server , I would like to send outlook emails on the client computer so that the users can keep track of the emails they send on their client computer.
I am using this code
public class EmailAPI
{
private ActiveXComponent ol;
private Dispatch outlook;
private Object mapi[] = new Object[1];
private Object email[] = new Object[1];
public EmailAPI()
{
mapi[0] = "MAPI";
email[0] = 0;
ol = new ActiveXComponent("Outlook.Application");
outlook = ol.getObject();
Dispatch.call(outlook,"GetNamespace",mapi).toDispatch();
}
public void createEmail(String receiver,String cc,String subject, String body, String attachments[])
{
Dispatch mail = Dispatch.call(outlook,"CreateItem",email).toDispatch();
//Dispatch mailItem = Dispatch.call(axOutlook, "CreateItem", 0).getDispatch();
Dispatch inspector = Dispatch.get(mail, "GetInspector").getDispatch();
Dispatch recipients = Dispatch.call(mail, "Recipients").getDispatch();
Dispatch.call(recipients, "Add" , receiver);
Dispatch.put(mail, "CC",cc);
Dispatch.put(mail, "Subject", subject);
Dispatch.put(mail, "Body", body);
if(attachments.length>0)
{
Dispatch attachs = Dispatch.get(mail, "Attachments").toDispatch();
for(Object attachment : attachments)
{
Dispatch.call(attachs, "Add", attachment);
}
}
Dispatch.call(mail, "Send");
}
}
Is there any possible way I can achieve that. I know a possible way to use a mailto: but got stuck on adding an attachment because basic requirement is to fill in the email address,subject,cc,message and attachment.
For sending emails I've used javax.mail library, its Java's library and its really simple to use. Don't see a need to go over JavaXComponent and to hook on Outlook library.
JavaMail (javax.mail) https://mvnrepository.com/artifact/javax.mail/mail/1.4.7
For simple mail sending and attachment sending, check out (as I mentioned before) javax.mail lib.
Import library, hook to You email, create simple message, add attachment(s), and Your good to go.
The Add method of the Attachments class accepts four parameter, one of them is required, others are optional.
Source - The source of the attachment. This can be a file (represented by the full file system path with a file name) or an Outlook item that constitutes the attachment.
Type - The type of the attachment. Can be one of the OlAttachmentType constants.
Position - This parameter applies only to e-mail messages using the Rich Text format: it is the position where the attachment should be placed within the body text of the message. A value of 1 for the Position parameter specifies that the attachment should be positioned at the beginning of the message body. A value 'n' greater than the number of characters in the body of the e-mail item specifies that the attachment should be placed at the end. A value of 0 makes the attachment hidden.
DisplayName - This parameter applies only if the mail item is in Rich Text format and Type is set to olByValue : the name is displayed in an Inspector object for the attachment or when viewing the properties of the attachment. If the mail item is in Plain Text or HTML format, then the attachment is displayed using the file name in the Source parameter.
For example, a sample VBA macro which illustrate a possible usage:
Sub AddAttachment()
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Set myItem = Application.CreateItem(olMailItem)
Set myAttachments = myItem.Attachments
myAttachments.Add "D:\Documents\Q496.xlsx", olByValue, 1, "4th Quarter 96 Results Chart"
myItem.Display
End Sub
So, basically you need to specify the full file path to the file you want to attach.
FYI Microsoft strongly recommends that developers find alternatives to Automation of Office if they need to develop server-side solutions. Because of the limitations to Office's design, changes to Office configuration are not enough to resolve all issues. Microsoft strongly recommends a number of alternatives that do not require Office to be installed server-side, and that can perform most common tasks more efficiently and more quickly than Automation. Before you involve Office as a server-side component in your project, consider alternatives. Read more about that in the Considerations for server-side Automation of Office article.

Getting an error code 80 on textlocal

I am using TextLocal tool to send SMS in my java code. I am using the same code snippet given here.
This is a transactional account. I am getting the following error
{"errors":[{"code":80,"message":"Invalid template"}],"status":"failure"}
This error code is nowhere found in the TextLocal documentation. Please let me know the solution if anyone has faced this issue before.
This was happening because the TextLocal transactional messages should be given a message template through the TextLocal dashboard and all the SMS sent should follow all the rules of these messages.
After the template has been created and followed, the issue is resolved.
go to Your login dashboard of textlocal
Then in send menu go to template and draft.
then open your template to see the message format.
And provide same massage format to your java method to send message.
Hope may it help you.
Few quick points to check
1.Is the message that you are passing in your API as per your approved
templates? If not, this error will come in response to your API. You
can check your approved templates under Send -> Templates & Drafts
2.Are all special characters in your template (&, #, #...) URL
encoded?
3.Are you using the same placeholder name
for multiple dynamic/replaceable parameters in your API? They have
to be unique.
4.Are you exceeding the max character length set for
the placeholder? Are you using a newline character? Replace all the
newline characters with %n
The above points are from textlocal SMS API documentation. You can also try copying the content of approved textlocal template into the Java code.
This because of the sending message content doesn't match the template which you created on the textlocal account.
check template is created or not. If not create a template and try.
If created check current message content match with your existing template.
This is happening because,
From a transactional account you can send only those messages that
match one of your pre-approved templates. Please ensure that your
messages match one of the approved template formats.
To create a Template,
Go to Your login dashboard of textlocal-> Send -> Templates and Drafts.
Then create a Template. Templates can be 2 types Static & Dynamic. You can create both by using this. Template message format should match the format in your code.
I am providing a link.. This will help to understand this more clearly.
How to create and format template

Set Outlook category on mail using Java

I'm trying to set custom categories on an email item programmatically using Java.
I found this: Setting an Outlook mailitem's category programmatically?
but I would like to do the same thing in Java. I guess some custom headers are set on the message, but I can't find information on which headers I should set. Anyone got information on this?
JMSG is Java API to create and read Outlook message files. It provides methods to set/get categories as well as many other headers.

How t set FieldType.USER in sharepoint file property with Java - Invalid data has been used to update the list item

I'm trying o use method CopyIntoItems and add to uploaded file owner property. Field Owner should be type USER. am setting up it like this:
FieldInformation fieldInformationUser = new FieldInformation();
fieldInformationUser.setDisplayName("Owner");
fieldInformationUser.setInternalName("Owner");
fieldInformationUser.setType(FieldType.USER);
fieldInformationUser.setValue("domain//username");
I'm using this library: Sharepoint library link
If TEXT type field is updated in presented above way - it passes, but does't update field at SharePoint server. Problem occurs when i'm using type USER - server returns
Invalid data has been used to update the list item. The field you are trying to update may be read only.
WSDL specifies fieldType.USER as a string field. he question is, how this string should look like... Anyone knows?
You must make sure that the user exists in the users table in SharePoint. It may be that it exists in AD but it hasn't been added to SharePoint yet.
If it were C#, then you would first issue the EnsureUser command:
//C# CSOM code
SPUser user=web.EnsureUser(userName);
listItem[fieldName] = user;
You should search for a similar method in the library you're using

Categories

Resources