Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Outlook Form: Run Script on Send

Posted on 2003-12-01
6
Medium Priority
?
723 Views
Last Modified: 2008-03-03
I'm currently coding a script that pops up a message box asking a user if they want to forward a copy of the e-mail they are sending to electronic document control.  This script works well enough when I link it to a command button, but I can't seem to get it to work when using the Send command.  Here is the script that works with the command button:

Sub CommandButton1_Click()    
    Set myItem = Application.ActiveInspector.CurrentItem
    answ = MsgBox ("Send a Copy to EDC?", vbYesNo )
    If (answ=vbYes) Then
        myItem.Recipients.Add("Electronic Document Control")
    End If
    Send
End Sub

And here is the code I am trying to get working with the Send function:

Function Item_Send()
    Set myItem = Application.ActiveInspector.CurrentItem
    answ = MsgBox ("Send a Copy to EDC?", vbYesNo )
    If (answ=vbYes) Then
        myItem.Recipients.Add("Electronic Document Control")
    End If
End Function

The error message I receive is - "The operation failed."  I have tried slipping a Send command into the function at the end, but it can't send in the middle of the Send function.

Operating System - Windows 2000 SP4
Application - Outlook 2000 (SP2)

Any help is greatly appreciated as I cannot find detailed references for the send function.

Garth
0
Comment
Question by:Braech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Expert Comment

by:jessnjeff
ID: 9852834
This may sound dumb, but I have been designing Outlook forms for over 2 years now and have NEVER gotten the send code to work.  I was forced to resort to removing all the toolbars so users can't use the send button and adding my own send button.  Or I cancel the action when the send button is used.  Not a real answer, but an alternative to your problem.
0
 

Author Comment

by:Braech
ID: 9867527
Jessnjeff,
     Any sample scripts for removing toolbars and cancelling send actions?  It must be frustrating as a forms designer to be unable to modify the default Send script to perform customized actions.  Thanks for the response.

Garth
0
 

Author Comment

by:Braech
ID: 9868217
After thinking over your solution, perhaps replacing the existing Send button with a macro button would be the way to go.  I've created a macro using the code below and then added it to the default mail message form using the Customize toolbar option.  Something along the lines of:

Sub EDC_Click()

    Set myItem = Application.ActiveInspector.CurrentItem
    answ = MsgBox("Send a Copy to EDC?", vbYesNo)
    If (answ = vbYes) Then
        myItem.Recipients.Add ("Electronic Document Control")
    End If
    myItem.Send

End Sub

This code prompts the user if he/she wants to include the EDC, but it fails at this point for some reason.  It appears to be caught up on the myItem.Send command, but perhaps you have an idea.  Thanks.

Garth
0
 

Author Comment

by:Braech
ID: 9868292
The problem appears to have been that Electronic Document Control was an invalid e-mail address.  Removing the standard Send button and replacing it with mine seems to fix the issue.  It has not disabled Ctrl-Enter Send command.
0
 
LVL 8

Accepted Solution

by:
jessnjeff earned 750 total points
ID: 9874437
Also, it is always a good idea to resolve all addresses before sending

Example


Set myRecipients = myItem.Recipients
If Not myRecipients.ResolveAll Then
    For Each myRecipient In myRecipients
        If Not myRecipient.Resolved Then
            OTHER CODE HERE
        End If
     Next
End If
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Changing a few Outlook Options can help keep you organized!
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question