Saving a form to Sent Folder

O

Outlook Worm

Hi,

I am using following code to save a form with its data to Sent folder.

Set nmsName = Application.GetNamespace("MAPI")
Set mpiFolder = nmsName.GetDefaultFolder(5)
Set newMessage = mpiFolder.Items.Add("IPM.Note.test")
newMessage.MessageClass="IPM.Note.test"
newMessage.Subject = "test Subject"
Set rcpt = newMessage.Recipients.Add("(e-mail address removed)")
rcpt.Resolve
If rcpt.Resolved Then
rcpt.Type = 1
End If
Set rcpt = Nothing
Set newMessage = Nothing

But it always gets to Drafts Folder. Please let me know what is wrong i
am doing ?


Khan G

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

Unsent messages always save in the Drafts folder, regardless of where you
create them. After you save the message, you should be able to use the Move
method to move it to Sent Items:

newMessage.Save
newMessage.Move mpiFolder
 
O

Outlook Worm

Thanks Sue. It worked. How can close form after moving it to Sent
Folder. I am facing another issue. I have some code in Item_Open event,
which loads data from an XML file to display in form. But when i save it
in Sent Folder, i want it to persist that data rather than newly loaded
data. When i reopen the item in Sent folder, it re-loads the data and
replaces the saved data. Any ideas ?

Khan G

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
O

Outlook Worm

Also, Can we disable The Maximize option for the Form ? And How is it
possible that all forms controls are resized according to the size of
the form. ? Thanks

Khan G

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

If you want to persist data, you must set the value of one or more Outlook
properties, since those are what hold the data. If you're loading unbound
controls in Item_Open, then you might need to load them with different data,
set a flag property on the item to tell Item_Open not to load data, etc.

You shouldn't have to close an item after moving it to the Sent Items
folder. You might want to show the relevant code snippet.
 
S

Sue Mosher [MVP-Outlook]

No, you can't disable the maximize option. If a control is set to resize,
Outlook resizes it automatically.
 
O

Outlook Worm

Sue,

I have all custom controls on the form. Only 'To' is default. I have set
the Property 'Resize with the form' checked. When we the dialog gets
resized, only 'To' gets resized with the form size but other controls
stay as before.

Khan G

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

I don't know what you mean by "'To' is default.'" What kinds of controls do
you have on the form? What kind of form is it?
 
O

Outlook Worm

This is based on Message Template. Default 'To' means the To Field,
which is part of the Message Form - Pressing which pops up the Select
Contacts Dialog. I deleted all other controls and have my own controls
like Combo box, Edit Box, Labels.

Also please let me know how can i install CDO ?

Khan G

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
S

Sue Mosher [MVP-Outlook]

YOu can install CDO 1.21 by running Office/Outlook setup and choosing the
Collaboration Data Objects component under Outlook.

Edit Box? Do you mean text box? Multi-line?

Also note: The newsgroup interface you are using apparently does not quote
earlier messages in the thread, making your latest message so short on
detail that you risk not getting the answer you're looking for. Please take
the time to quote the original message.
 

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