Outlook , VBScript e html form.. HELP

  • Thread starter Thread starter .-=] ExTrEmE [=-.
  • Start date Start date
E

.-=] ExTrEmE [=-.

Hi all!
I hope you can understand my english :P

I'll explain my question.
In my office we use an old html form to send some short infos to an email
account, by a simple mailto: link.
We use Office 2003 and exchenge mail accounts.
Each worker have a personal mail account and can access to shared office
mailbox.
For some reasons(little stupit in my opinion.. :-/ ) the mail with form data
need to be sent from office mailbox, and should be found in the same account
sent box.
Normally any worker configure outlook with personal mail box as primary and
office shared as secondary, but this configuration force the worker to
reconfigure outlook to send form data (office as primary, personal as
secondary).

A waste of time.. and little boring.

I'll want to make all more simple and speedy.
I'd wrote the vb script do send my form data by mail from specified account,
using Outlook objects.
Let see (sorry mix of italian and english for variables and comments
:-P )...

<script language="vbscript">

Sub Invia_Mail(Destinatario, Oggetto , CorpoMail, InviatoDa)

'Crea l'oggetto outlook
Dim Outlook
Set Outlook = CreateObject("Outlook.Application")

'Crea l'oggetto messaggio
Dim Message
Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = Oggetto
.HTMLBody = CorpoMail 'qui creo via script il mio body in html a
partire dai dati inseriti nel form html
'Aggiungiamo il destinatario
.Recipients.Add (Destinatario)
'se è stato inserito un indirizzo email dal quale deve partire la mail,
lo si imposta qui
If Len(InviatoDa) > 0 Then .SentOnBehalfOfName = InviatoDa

'e adesso inviamo
.Send
End With
End Sub
</script>

All fork fine. Mail built and sent. Wow :-D
But there are some things that don't go.
And there a question that I leave at last (the main reason for my post).

1) Some security messages are shown before mail being sent, with the obvious
request to start or not mail message. I think there's no way (obvious) to
workaround this by script.. but there's a local security setting to avoid
this request?

2) Next i found that mail in outbox.. but it not go away!! Clicking on
sent/receive take no effects! The only way is to click on time on outbox...
the mail start immediately (????).
Is it a local problem.. or a bug.. or something else?

3) Now come my real question :)
All beautiful, all work.. goooood! NOT!
My sent mail be placed on my personal account if configured as primary :°(
I need it to be in the sent box of office account! :(
I want to check by script the "From" account.. and if personal account found
i need to make a copy of the message (or move) and place it in the office
Sent Box.
There's a problem.. How can I do it? :-D
I've asked to Dr. Google :) but now I'm little confused :-P

3b) There's a way to check the configured accounts before all my damn
things? How?

I hope someone give me the light to show me the way :)

Many Thanks!
 
1) Unavoidable in external Outlook 2003 automation code unless security is loosened by the Exchange administrator. See http://www.outlookcode.com/article.aspx?ID=52 for alternative approaches.

2) Quite possibly completely unrelated to your application and instead related to an add-in installed on the machine. Does the same behavior happen with messages sent manually?

3) Set the SentOnBehalfOfName property to the mailbox alias or email address that you want to send from. Getting it into the Sent Items folder of the other mailbox is not possible with a simple web-page script , as you must wait until the item is delivered to the server and appears in the Sent Items folder. Only then can you move it to the other mailbox's Sent Items folder.

Just a thought: Would copying the other mailbox with a Bcc be enough?

3b) Sorry, but I don't understand the question.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


.-=] ExTrEmE [=-. said:
Hi all!
I hope you can understand my english :P

I'll explain my question.
In my office we use an old html form to send some short infos to an email
account, by a simple mailto: link.
We use Office 2003 and exchenge mail accounts.
Each worker have a personal mail account and can access to shared office
mailbox.
For some reasons(little stupit in my opinion.. :-/ ) the mail with form data
need to be sent from office mailbox, and should be found in the same account
sent box.
Normally any worker configure outlook with personal mail box as primary and
office shared as secondary, but this configuration force the worker to
reconfigure outlook to send form data (office as primary, personal as
secondary).

A waste of time.. and little boring.

I'll want to make all more simple and speedy.
I'd wrote the vb script do send my form data by mail from specified account,
using Outlook objects.
Let see (sorry mix of italian and english for variables and comments
:-P )...

<script language="vbscript">

Sub Invia_Mail(Destinatario, Oggetto , CorpoMail, InviatoDa)

'Crea l'oggetto outlook
Dim Outlook
Set Outlook = CreateObject("Outlook.Application")

'Crea l'oggetto messaggio
Dim Message
Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = Oggetto
.HTMLBody = CorpoMail 'qui creo via script il mio body in html a
partire dai dati inseriti nel form html
'Aggiungiamo il destinatario
.Recipients.Add (Destinatario)
'se è stato inserito un indirizzo email dal quale deve partire la mail,
lo si imposta qui
If Len(InviatoDa) > 0 Then .SentOnBehalfOfName = InviatoDa

'e adesso inviamo
.Send
End With
End Sub
</script>

All fork fine. Mail built and sent. Wow :-D
But there are some things that don't go.
And there a question that I leave at last (the main reason for my post).

1) Some security messages are shown before mail being sent, with the obvious
request to start or not mail message. I think there's no way (obvious) to
workaround this by script.. but there's a local security setting to avoid
this request?

2) Next i found that mail in outbox.. but it not go away!! Clicking on
sent/receive take no effects! The only way is to click on time on outbox...
the mail start immediately (????).
Is it a local problem.. or a bug.. or something else?

3) Now come my real question :)
All beautiful, all work.. goooood! NOT!
My sent mail be placed on my personal account if configured as primary :°(
I need it to be in the sent box of office account! :(
I want to check by script the "From" account.. and if personal account found
i need to make a copy of the message (or move) and place it in the office
Sent Box.
There's a problem.. How can I do it? :-D
I've asked to Dr. Google :) but now I'm little confused :-P

3b) There's a way to check the configured accounts before all my damn
things? How?

I hope someone give me the light to show me the way :)

Many Thanks!
 
2) Quite possibly completely unrelated to your application and instead
related to an add-in installed on the machine. Does the > same behavior
happen with messages sent manually?

No.. with mail sent directly from outlook all ok.
3) Set the SentOnBehalfOfName property to the mailbox alias or email
address that you want to send from.

With my actual script i set this property and the mail start with correct
account.
Getting it into e Sent Items folder of the other mailbox is not possible
with a simple web-page script , as you must wait until
the item is delivered to the server and appears in the Sent Items folder.
Only then can you move it to the other mailbox's Sent
Items folder.

mm... Alternative: can i force my script to put 'manually' the message in
the sent folder of other account? With a thing like this:

Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = MySubject
.HTMLBody = MybodyContent
.Recipients.Add (MyRecipient)
If Len(InviatoDa) > 0 Then .SentOnBehalfOfName = FromCorrectAccount
.Send
' TODO: Error checking to know if sent or none.

End With
' if no errors on send..
'.. i'll check if the primary account is the personal or office with a
function like this (obviously dummy :P )
Primary=CheckPrimaryAccount
'and copy my message manually to Office Sent Box.. with drag&drop i
can.. but with scripting?
if Primary<>Office_Account then PutMyMessage(Message, Office_Sentbox)

Is it a correct (and possibile) way?
Just a thought: Would copying the other mailbox with a Bcc be enough?
no :(

There are three mail accounts in that game: Personal, Office, Supervisors.
They want form data starting from Office account to supervisors account;
they want also to find a copy of message in Office Sent Box. No other way
(i've asked.. :( )

Don't ask me why. Really i can't understand this perverse logic :P
(They use a pc just for miracle.. ;) )

We can avoid all the problems with a manual drag & drop form personal sent
box to office sent box.. but someone can remember to do this.. someone not..
:-/
3b) Sorry, but I don't understand the question.

Sorry :-P
Is possible, by vbscript, to get the actully configured accounts (addresses
or aliases) on outlook?
If yes.. is possibile to know the primary account?

Many thanks again!!!

Simone
 
1) Unavoidable in external Outlook 2003 automation code unless security is
loosened by the Exchange administrator.
See http://www.outlookcode.com/article.aspx?ID=52 for alternative
approaches.

Today I'll check.. CDO could be a great solution.. if i can use it.
The HTML forms ar not on a web server, but stored in a network drives (i've
suggested a littel local web server form office.. but no way :-/)

Note that my office is in a big network environment (bank) and every client
configuration is standard.. with standard applications, standard components
and so on..

We have an intranet built with sharepoint and many advanced feature..
But for some stupid reasons in my office they want to use a preistoric way
to do things.. but this is another story..
:-/
 
can i force my script to put 'manually' the message in
the sent folder of other account?

No, because, as I said, you can't move the message until it is in the Sent Items folder. While the MailItem object has a SaveSentMessageFolder property, I don't think it works if you set it to a folder in another mailbox. (Feel free to try it and prove me wrong, though.)

Possible solutions would include:

1) an add-in running on each sending machine to move the items from Sent Items
2) an Exchange event sink running on the server to process new items in each sending mailbox's Sent Items folder
3) a script to come around some time after the send and look for items in the Sent Items folder that need to be refiled to the other mailbox
Is possible, by vbscript, to get the actully configured accounts (addresses
or aliases) on outlook?
If yes.. is possibile to know the primary account?

Not with the Outlook object model in Outlook 2003. You would need to use Outlook 2007, Extended MAPI, or the ProfMan library from Redemption -- or hack the Windows Messaging Subsystem\Profiles portion of the Windows registry.

As for your #2 problem, try calling SyncObject.SyncStart to kick off a send/receive.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


.-=] ExTrEmE [=-. said:
2) Quite possibly completely unrelated to your application and instead
related to an add-in installed on the machine. Does the > same behavior
happen with messages sent manually?

No.. with mail sent directly from outlook all ok.
3) Set the SentOnBehalfOfName property to the mailbox alias or email
address that you want to send from.

With my actual script i set this property and the mail start with correct
account.
Getting it into e Sent Items folder of the other mailbox is not possible
with a simple web-page script , as you must wait until
the item is delivered to the server and appears in the Sent Items folder.
Only then can you move it to the other mailbox's Sent
Items folder.

mm... Alternative: can i force my script to put 'manually' the message in
the sent folder of other account? With a thing like this:

Set Message = Outlook.CreateItem(olMailItem)
With Message
.Subject = MySubject
.HTMLBody = MybodyContent
.Recipients.Add (MyRecipient)
If Len(InviatoDa) > 0 Then .SentOnBehalfOfName = FromCorrectAccount
.Send
' TODO: Error checking to know if sent or none.

End With
' if no errors on send..
'.. i'll check if the primary account is the personal or office with a
function like this (obviously dummy :P )
Primary=CheckPrimaryAccount
'and copy my message manually to Office Sent Box.. with drag&drop i
can.. but with scripting?
if Primary<>Office_Account then PutMyMessage(Message, Office_Sentbox)

Is it a correct (and possibile) way?
Just a thought: Would copying the other mailbox with a Bcc be enough?
no :(

There are three mail accounts in that game: Personal, Office, Supervisors.
They want form data starting from Office account to supervisors account;
they want also to find a copy of message in Office Sent Box. No other way
(i've asked.. :( )

Don't ask me why. Really i can't understand this perverse logic :P
(They use a pc just for miracle.. ;) )

We can avoid all the problems with a manual drag & drop form personal sent
box to office sent box.. but someone can remember to do this.. someone not..
:-/
3b) Sorry, but I don't understand the question.

Sorry :-P
Is possible, by vbscript, to get the actully configured accounts (addresses
or aliases) on outlook?
If yes.. is possibile to know the primary account?

Many thanks again!!!

Simone
 
CDO for Windows would not meet your requirements, because it would not create a copy in the Sent Items folder.

I still think Bcciing the other account is a good solution -- if you combine it with a server-side rule or Exchange event sink to move items to the Sent Items folder.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


.-=] ExTrEmE [=-. said:
1) Unavoidable in external Outlook 2003 automation code unless security is
loosened by the Exchange administrator.
See http://www.outlookcode.com/article.aspx?ID=52 for alternative
approaches.

Today I'll check.. CDO could be a great solution.. if i can use it.
The HTML forms ar not on a web server, but stored in a network drives (i've
suggested a littel local web server form office.. but no way :-/)

Note that my office is in a big network environment (bank) and every client
configuration is standard.. with standard applications, standard components
and so on..

We have an intranet built with sharepoint and many advanced feature..
But for some stupid reasons in my office they want to use a preistoric way
to do things.. but this is another story..
:-/
 
No, because, as I said, you can't move the message until it is in the Sent
Items folder. While the MailItem object has a
SaveSentMessageFolder property, I don't think it works if you set it to a
folder in another mailbox. (Feel free to try it and
prove me wrong, though.)

Many many thanks. I've solved my problem with this property. Locally, with
only one personal account, it work if i set the SaveSentMessage to a
sub-folder of sent box.

If it work @office.. i've all what i'm searching for :)

many thanks
--
Simone(27,105,SI)
- Alfa 147 1.6 T.S. 105cv BlackLine
- MG ZR105 Ex Driver
- Suzuki Sv650 Rider
- Alfa75 Lover
 
--
Simone(27,105,SI)
- Alfa 147 1.6 T.S. 105cv BlackLine
- MG ZR105 Ex Driver
- Suzuki Sv650 Rider
- Alfa75 Lover

Sorry.. sign for other car's related newsgroup :-)
 
Back
Top