The sender problems, help me pls?

R

ryotyankou

I'm using VC++2005 and ATL to develop a outlook addin. I have two problems:
1. I want to get the sender name of CurrentItem when send mail(outlookspy). I
searched a lot on the internet. Finally i use the MAPI to get it, it is ok,
but the receiver can't open the message(encrypted).
What i do is that MailItem->Save, then getprops InetAcct_GUID = { 0x00062008,
0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46 } };id =
0x8581; I don't know the reason. How could i get the sender string?
2. How could i set the account to send email in background? Say i have two
accounts A and B, A is the default account, when C send a mail to B, I want
to use B automatically reply a message to C. But the default account is A,
how could i use B to send it?
Any tips or advices will be good, thx.
 
R

ryotyankou

After search the other forum, i found a way to fix my first problem, i will
try it(I almost known nothing to VB).
 
R

ryotyankou via OfficeKB.com

My first problem is fixed, save the item, the getprops, it is ok. The error i
said before is caused by other reason.
Then, how about my second problem? Thx very much.
 
R

ryotyankou via OfficeKB.com

Thank you Dmitry, but how about outlook2003, the main task of our product
should be implemented on 2003 not 2007.(I known outlook2007 have some new
interfaces and structruces can do the job easily).
 
D

Dmitry Streblechenko

You can set these properties using Extended MAPI (shouldn't be a problem if
you are using C++) - IMessage interface can be obtained through the
MailItem.MAPIOBJECT property. To retrieve the accoutn naame and id, use the
IOlkAccountManager interface.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
R

ryotyankou via OfficeKB.com

That's great, i will try it tommorrow. How can i use this interface to set
the account to send email? I find a sample on codeproject.com. It can
retrieve all accounts, but how to set the default account, the SetOrder()
function? But how could i know which one is the current default account?
Thanks very much.
 
D

Dmitry Streblechenko

The first account in the list returned by IOlkAccountManager::GetOrder
method is teh default one.
You can play with IOlkAccountManager in OutlookSpy - click Misc |
IOlkAccountManager.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
R

ryotyankou via OfficeKB.com

Thank you Dmitry, the IOlkAccountManager can Set the default account, but i
still have question here.
Say A is the default account, B is another, and C send a message to B. B
should auto reply a message to C.
This is my code flow for repy message to C:
1. Set specified account(B) as default.(SetOrder)
2. Create the message and send it.
3. Restore the original account(A).(SetOrder again)
well, the problem is that How could i known when the message is already sent.
The result of my code is alway send by A. If i mark the 3. It can work(send
by B). But it is bad for that change the default account and user may don't
know that, right?
In one word, when should i do the action 3?
Thanks in advance.
 
D

Dmitry Streblechenko

Do not reset the default account, simply set the appropriate named
properties on the message to tell Outlook which account it should use for
sending.

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
R

ryotyankou via OfficeKB.com

Could you pls tell me which properties i should use. CurrentItem-
SendOnBehalfOfName(Exchange only)can't work, mine is POP3/SMTP. Also I
change the IMessage's 0x8013 InetAcctID and InetAcctName manually, it still
use the default account to send my mail. The PR_SENDEMAIL_ADDRESS,
PR_SENDEMAILNAME can't work at all. And I can't find PR_PRESENTING_XXXX in
IMessage via outlookspy.
 
R

ryotyankou via OfficeKB.com

Hi, Dmitry. I have successfully set the PR_SENT_REPRESENTING_XXX. Say,
Outlook have two accounts, (e-mail address removed)(default), (e-mail address removed). Then ccc@ccc.
com send a message to (e-mail address removed). ok, my code generate a message, and sent
it to (e-mail address removed). But it is strange that the message (e-mail address removed) received is
something like(you should open the mail by double click the message):
FROM: (e-mail address removed) representing (e-mail address removed)
TO: (e-mail address removed)

But the item in folder show that the sender is (e-mail address removed).
So actually, the message is send by the default account (e-mail address removed). What
should i do to use (e-mail address removed) send the mail? Or just change "FROM: aaa@aaa.
com representing (e-mail address removed)" to "(e-mail address removed)."
 
D

Dmitry Streblechenko

How exactly do you send the message?
Are you sure you set these properties correctly? Did you compare the values
to the messages sent through through teh UI?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
R

ryotyankou via OfficeKB.com

oh, no, Should this be a bug for this discuss forum? I posted a reply, but
when you are in reply action, you can't see it. After you click post button,
you can see the reply i were posted.
////////////////////////////This is what i posted last
time//////////////////////////////
Hi, Dmitry. I have successfully set the PR_SENT_REPRESENTING_XXX. Say,
Outlook have two accounts, (e-mail address removed)(default), (e-mail address removed). Then ccc@ccc.
com send a message to (e-mail address removed). ok, my code generate a message, and sent
it to (e-mail address removed). But it is strange that the message (e-mail address removed) received is
something like(you should open the mail by double click the message):
FROM: (e-mail address removed) representing (e-mail address removed)
TO: (e-mail address removed)

But the item in folder show that the sender is (e-mail address removed).
So actually, the message is send by the default account (e-mail address removed). What
should i do to use (e-mail address removed) send the mail? Or just change "FROM: aaa@aaa.
com representing (e-mail address removed)" to "(e-mail address removed)."
////////////////////////////////////////////////Last posted
end//////////////////////////////////
As i mentioned in this post, and i check the message while receive it. The
PR_SENT_REPRESENTING_XXX is currently set.
My questiones are:
1. What should i do to use (e-mail address removed) send the mail?
2. Or just change "FROM: (e-mail address removed) representing (e-mail address removed)" to "bbb@bbb.
com."


Dmitry said:
How exactly do you send the message?
Are you sure you set these properties correctly? Did you compare the values
to the messages sent through through teh UI?
Could you pls tell me which properties i should use. CurrentItem-
SendOnBehalfOfName(Exchange only)can't work, mine is POP3/SMTP. Also I [quoted text clipped - 7 lines]
properties on the message to tell Outlook which account it should use for
sending.
 
D

Dmitry Streblechenko

You are posting through officekb.com, not direcly to the Microsoft server.
I saw your reply just fine, but I don't think you answered my questions:

1. How exactly do you send the message?
2. Are you sure you set these properties correctly? Did you compare the
values to the messages sent through through the UI? I mean the message
properties that hold the account name and id, not the
PR_SENT_REPRESENTING_XXX properties.


--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
ryotyankou via OfficeKB.com said:
oh, no, Should this be a bug for this discuss forum? I posted a reply, but
when you are in reply action, you can't see it. After you click post
button,
you can see the reply i were posted.
////////////////////////////This is what i posted last
time//////////////////////////////
Hi, Dmitry. I have successfully set the PR_SENT_REPRESENTING_XXX. Say,
Outlook have two accounts, (e-mail address removed)(default), (e-mail address removed). Then
ccc@ccc.
com send a message to (e-mail address removed). ok, my code generate a message, and
sent
it to (e-mail address removed). But it is strange that the message (e-mail address removed) received
is
something like(you should open the mail by double click the message):
FROM: (e-mail address removed) representing (e-mail address removed)
TO: (e-mail address removed)

But the item in folder show that the sender is (e-mail address removed).
So actually, the message is send by the default account (e-mail address removed). What
should i do to use (e-mail address removed) send the mail? Or just change "FROM:
aaa@aaa.
com representing (e-mail address removed)" to "(e-mail address removed)."
////////////////////////////////////////////////Last posted
end//////////////////////////////////
As i mentioned in this post, and i check the message while receive it. The
PR_SENT_REPRESENTING_XXX is currently set.
My questiones are:
1. What should i do to use (e-mail address removed) send the mail?
2. Or just change "FROM: (e-mail address removed) representing (e-mail address removed)" to
"bbb@bbb.
com."


Dmitry said:
How exactly do you send the message?
Are you sure you set these properties correctly? Did you compare the
values
to the messages sent through through teh UI?
Could you pls tell me which properties i should use. CurrentItem-
SendOnBehalfOfName(Exchange only)can't work, mine is POP3/SMTP. Also I
[quoted text clipped - 7 lines]
properties on the message to tell Outlook which account it should use
for
sending.
 
R

ryotyankou via OfficeKB.com

OK, let me make it clear.
1. When a new message were added to inbox(Outlook::ItemsEvents, 0x0000F001,
OnItemAdd, &OnItemAddInfo). I will check if this message need to be processed.
Then Get IMAPIFolder interface, QueryInterce for IMessage, then call IMessage:
:CreateMessage. Now set properties for this message.
PR_RECIPIENT_TYPE, PR_DISPLAY_NAME, PR_MESSAGE_CLASS, PR_SUBJECT, PR_HTML,
PR_SENDER_XXXX(Do not work so i set PR_SENT_REPRESENTING_XXX instead, So the
created message's from field is alway a string like: "(e-mail address removed) on behalf of
(e-mail address removed)" which (e-mail address removed) is the default account.), and so on. then SaveChanges.
SubmitMessage.
2. SetProps return S_OK, and i checked the returned LPSPropProblemArray too,
it is NULL, so i conclude that the function is sucessfully executed. After
message were sent, i found that PR_SENT_REPRESENTING_XXX is ok, but
PR_SENDER_XXX get overwritten by default account.
Are these answers useful to your analysis?
 
R

ryotyankou via OfficeKB.com

I noticed that if i choose sender by click droplist and then save the message.
Just two properties is changed obviously. Do you mean the two properties? In
fact, i tried these two before, but i didn't know how to set them, i search
through the network, but found too few to use. Can you help me for that how
can i do deal with this? Any tips or links will ok. Thank you in advance.
 
R

ryotyankou via OfficeKB.com

I'm sorry for reply so frequently, i found some code snippets and then set
InetAcctID and InetAcctName sucessfully. But unlucky it is not work, i
checked the sent mail, these two properties were set ok but mail is still
sent by default account.
Until now, my conclusion is:
1. Set PR_SENDER_XXX will be overwritten. While Set PR_REPRESENTING_XXX will
set the sender as
FROM: "(e-mail address removed)(default account) on behalf of (e-mail address removed)(this is the account i
want to use to send the mail).
TO: (e-mail address removed)
The mail item in folder show the sender is (e-mail address removed)(in fact, (e-mail address removed) sent the
mail). Am i right?
 
D

Dmitry Streblechenko

After you set these two properties, does Outlook display the right account
when you open the message?
Youy are sending through SMTP, not Exchange, right?

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
 
R

ryotyankou via OfficeKB.com

Thank very very much, Dmitry, i slove it.
1. First set InetAcctID and InetAcctName. After this do NOT submit the
message, or it will still use the default account to send.
2. Open draft folder, get the message created just now(MailItem), then send
it, it will use the specified account to send the message.
Thanks in advance. ^_^
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top