I'm currently developing an application that handles mail for mailboxes automatically. We use the tool Outlook Redemption and connect with one service account to multiple Exchange mailboxes.
Case
The problem we face is forwarding mail from the original mailbox. Say service account 'A' is handling shared mailbox 'B' and is forwarding mail. I'd like the sender to be the mail address of 'B', but when I receive the mail the mail address of 'A' shows up as sender.
Source code
// Initialize the session with the service account.
_session = new RDOSession();
_session.LogonExchangeMailbox(configurationSettings.MailAddress, configurationSettings.Url);
// Connect to the target mailbox and retrieve mail message.
RDOStore store = _session.Stores.GetSharedMailbox(targetMailBox);
RDOMail originalMailItem = store.GetMessageFromID(entryId);
// Creates a forwarded version of the mail.
RDOMail forwardMailItem = originalMailItem.Forward();
// Set sender to target mailbox owner.
if (store is RDOExchangeMailboxStore)
{
forwardMailItem.Sender = ((RDOExchangeMailboxStore)store).Owner;
forwardMailItem.SenderEmailAddress = targetMailBox;
}
// Set recipient and send.
forwardMailItem.Recipients.Clear();
forwardMailItem.Recipients.Add(forwardMailAddress);
forwardMailItem.Send();
Questions
Anyone got a clue on a solution?
If this won't work, is it possible to get the mail address of 'B' in the 'On behalf of' rule?
Thanks in advance!!
The problem is that the message being forwarded is created in the primary store in the profile, not the delegate mailbox.
Besides setting the Sender property, have you tried to also set the SentOnBehalfOf property?
Related
I try to forward a Message through EWS with the following code:
EmailAddress[] adresses = { "servicedesk#example.com", "allschwil_sox#example.com" };
newEmailMessage.Forward("Account access has been removed according to attached Report", adresses);
example.com beeing our company domain. For some unknown reason, the email is not forwarded to our domain (servicedesk#example.com) but to another company: servicedesk#lifetech.com. Does anyone know how that can happen?
Allschwil_Sox#example.com got sent correctly to allschwil_sox#example.com
I am trying to send message from server email to my gmail
WebMail.SmtpServer = "mail.marekjedrysiak.com";
WebMail.SmtpPort = 25;
WebMail.EnableSsl = true;
WebMail.UserName = "mail#marekjedrysiak.com";
WebMail.Password = "******";
WebMail.From = "mail#marekjedrysiak.com";
WebMail.Send("marekjedrysiak1#gmail.com", "Message from server",null);
then coming this message :
Please help :(
This isn't an ASP.NET or C# related problem, your domain doesn't have an MX record. You can confirm this by checking http://www.mxtoolbox.com.
I see that your domain is registered with Tucows (Hover). In order to change your MX records:
Log in to your Hover account. If you have multiple domain names, select your marekjedrysiak.com domain.
Click the DNS tab.
Click Add New.
For Record Type, select MX.
Enter the address of your mail server.
Click Save.
If you need more help setting up or debugging your mail service, you should contact Hover's support. They can also advise you on what exactly to enter as the address of your mail server.
Source:
https://help.hover.com/hc/en-us/articles/217282457-How-to-Edit-DNS-records-A-CNAME-MX-TXT-and-SRV-Updated-Aug-2015-
Is there a way to get the primary SMTP address from an exchange account in Outlook ? I am currently using Redemption and following code keeps returning an empty value.
> IRDOExchangeAccount exAcc = (IRDOExchangeAccount)rdoAcc;
> string email = exchangeAccount.CurrentUser.SMTPAddress;
Currently I am using
exchangeAccount.CurrentUser.Address
property to get the Email and seems it gets me the correct Email address. How reliable that property is ? Is there another better way ?
Is it possible to restrict the user to reply to a mail sent via SMTP server?
I have tried using obsolete before the method name but still reply mail could not be blocked
void sendmail()
{
string to = "abc#xyz.com";
string from = "def#abc.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = #"Test"
SmtpClient client = new SmtpClient(server);
client.UseDefaultCredentials = true;
}
above is the sample code.
As others have said in the comments, it is impractical/impossible (depending on level of access to their computers) to prevent a user replying to an email. However, you can prevent an exchange email account from receiving emails by applying delivery restrictions - telling the account to only receive emails from itself:
On the server running Exchange start "Active Directory Users and Computers"
Find the account.
Double click the account to open its properties (or right click and select "Properties")
On the "Exchange General" tab, click [Delivery Restrictions...].
Under "Message restrictions" check "From authenticated users only". Then select the radio button "Only from" and add the user account. It is important that you add a user account here otherwise Exchange will accept email from any authenticated user.
Click [OK] to close the "Delivery Restrictions" dialog and [OK] again to close the account properties dialog.
Using this method, to any other user it will look like the account does not exist and they will receive delivery failed messages.
This an other methods are detailed here: http://www.cryer.co.uk/brian/msexchange/exch_howto_disable_delivery.htm
From an AddressEntry instance I'm calling GetExchangeUser or GetExchangeDistributionList methods to get PrimarySmtpAddress. This works fine when the AddressEntry has a DisplayType of olUser or olDistList, but both return null for an address with DisplayType of olForum.
The Exchange address does have an associated SMTP address. In Outlook I can type the address into "To" on a new email and it resolves to the appropriate Exchange user. Double-click on the user and an SMTP address does show. I just can't find a way to get to it through the Outlook object model.
If the SMTP address is available on that address entry, you should be able to retrieve it using AddressEntry.PropetyAccessor.GetProperty.
Take a look at that address entry using OutlookSpy (I am its author) - if you already have a message with that GAL entry as one of the recipients, select it in Outlook, click IMessage button on the OutlookSpy ribbon, go to the GetRecipientTable tab, double click on the recipient.
Do you see PR_SMTP_ADDRESS property? How about PR_EMS_AB_PROXY_ADDRESSES? Both properties can be retrieved using AddressEntry.PropetyAccessor.GetProperty