Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

sending an email from different address #605

@sunnykeerthi

Description

@sunnykeerthi

I'm writing a program that has auto response in it. i.e. for example there is an user ad his email address would be user@domain.com, when ever someone writes an email to this address, there should be an auto response sent (Which I'm able to do it). but this should be sent from autoReply@domain.com(this is what I'm unable to know on how to do this). autoReply@domain.com is a shared mail box.

I'm using ews in my program and the below block of code is responsible to send the auto response.

private void replyToEmailWithURLs(ItemId itemId, List matchedKeyWords, String fromAddress) throws Exception {
        EmailMessage message = EmailMessage.bind(service, itemId, new PropertySet(BasePropertySet.IdOnly));
        ResponseMessage responseMessage = message.createReply(false);

        message.getReplyTo().add(new EmailAddress("autoReply@domain.com"));
        // Add autoReply in CC
        responseMessage.getCcRecipients().add("autoReply@domain.com");
        String responseUrls = getTheResponseUrlsFromJsonFile(matchedKeyWords, fromAddress);
        responseMessage.setBodyPrefix(new MessageBody(BodyType.HTML, responseUrls));
        responseMessage.sendAndSaveCopy();
        message.setIsRead(true);

    }

Here I tried to add a replyTo using message.getReplyTo().add(new EmailAddress("autoReply@domain.com"));, even this doesn't work.

I've seen a post here http://stackoverflow.com/questions/35988918/set-reply-to-address-in-outgoing-email-ews , I was confused on the way it is working(basically given in c#), please let me know how can I get this done in Java.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions