There I have an issue hope so I will get the right answer here. I have an real estate business. I am using the outlook calendar to book the meetings. but when I am assigning the time to the user or doing any edit-related operation that time another user is getting the mail alerts.i want to disable those I only want to send those the appointment mail noting else. is there any way to disable those emails?
The Application.ItemSend event is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program. So, if you need to prevent anything from sending out, you can set the Cancel parameter to false, for example, a VBA handler is shown below:
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & Item.Subject & "?"
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
Cancel = True
End If
End Sub
Related
Does anyone know how to trigger VBA when i sent out an email.
I tried to look for the option from Rule Wizard on "Apply rule on message i send" but there is script option.
Cheers
Of course, you may assign a VBA sub to run when your rule is triggered. The sub should take a single argument which represents the item being sent:
Public Sub Test(item as Outlook.MailItem)
' run your code here
End Sub
You may add an event handler to the ItemSend event of the Application class. It is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program.
Public WithEvents myOlApp As Outlook.Application
Public Sub Initialize_handler()
Set myOlApp = Outlook.Application
End Sub
Private Sub myOlApp_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim prompt As String
prompt = "Are you sure you want to send " & Item.Subject & "?"
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
Cancel = True
End If
End Sub
You write an event procedure (also known as an event handler) to respond to events that occur in Microsoft Outlook. For example, you can write an event procedure that automatically maximizes the explorer window when Outlook starts.
Events are associated with particular objects. The Application object is the topmost object, and is always available (that is, it does not have to be created). You can add an Application event procedure in the ThisOutlookSession module window simply by selecting Application in the left list and then selecting the event in the right list.
My VBScript is running in system account I need a Confirmation Message Box With Yes/no option to popup and be visible to user. I am able to display the message box using this command
ObjShell.run "cmd.exe /C "" MSG * /SERVER:" &IP& " " &Str_Message &""&""""
but I need yes and no confirmation box and fetch user Choice there.
Here is the documentation on the MsgBox function.
Here's an example of that code. These constants are built into vbscript, so you don't need to declare them. The vbSystemModal value will cause the message box to be "modal" - as in, it will appear on top of all other windows until it is dismissed.
userInput = MsgBox("Prompt",vbExclamation+vbYesNo+vbSystemModal,"Title")
Select Case userInput
Case vbYes
MsgBox "User pressed yes."
Case vbNo
MsgBox "User pressed no."
End Select
Note that you might want to be careful with an unexpected popup to end users, especially as it relates to which button is default and if the dialog is modal. If a user is typing and they hit spacebar when the box pops up, they might select the default button without reading the message first. You might consider the vbDefaultButton1 or vbDefaultButton2 values to assign a default button.
I have a situation similar to the following simplified description:
A form with a TextBox (call it txtQty) in which a user can enter an integer. The event txtQty_Validate is used to validate the user input and force them to correct any errors before changing focus. This works great with all other controls on the form except for said txtQty. I assume that this is because the Cancel button on the form has the property CausesValidation necessarily set to false; thus when the user Tabs from txtQty to the Cancel button (whose TabIndex is next) it does not appropriately trigger the txtQty_Validation event.
My first instinct was to simply go to the txtQty_KeyPress event (which I am already using to make the RETURN key behave as TAB key) and capture the TAB key and temporarily toggle the CausesValidation property to allow the txtQty_Validation event to fire. However, it seems as though capturing the TAB key is not as easy as I had thought it would be.
Any suggestions? I assume that this cannot be the first time anybody creating a Form has come across such a situation.
Thanks
You could try this in the Cancel GotFocus event.
Dim b As Boolean
Call txtQty_Validate(b)
If b Then txtQty.SetFocus
Assuming you have something like this
Private Sub txtQty_Validate(Cancel As Boolean)
If Not IsNumeric(txtQty.Text) Then
Cancel = True
End If
End Sub
I've got the following AppleScript (below). I'm attempting to confirm the sending of an email. This AppleScript is already successfully hooked up to an "outbox rule" (using Mail Act-On) in Mail.app, and I've verified that it runs when it is supposed to (at the time of sending).
The ultimate goal is to pop a dialog to the user, asking if they "really" want to send the email. If not, stop the email from being sent.
The current script attempts to delete the message, but that doesn't work. Any ideas?
using terms from application "Mail"
on perform mail action with messages messageList for rule theRule
repeat with thisMessage in messageList
set theResult to display dialog "Send?" buttons {"OK", "Cancel"} default button 2
if button returned of theResult is not equal to "OK" then
delete thisMessage
end if
end repeat
end perform mail action with messages
end using terms from
I think that a "Cancel" button in a display dialog will immediately end execution of your script which means that the delete thisMessage line never is run.
You might try changing that to something like:
set theResult to display dialog "Send?" buttons {"OK", "No, Delete Message"} default button 2
if button returned of theResult is not equal to "OK" then
...
I'm developing an Access 2003 Database that uses a MS SQLServer backend.
I'm trying to do Form Validation and am experiencing some problems.
ValidationRule for each field seems to be ignored
I can't figure out what event I should override to enforce validation without having the database do it. (I'm not against this, it's just unknown to me how I'd catch Error Messages, instead of displaying them to the user)
I've tried getting around number 2 by disallowing closing and enforcing the use of a "Close Button", but the user can side step it by pressing tab, or by pressing the "Next Record" button at the bottom.
Any suggestions would be greatly appreciated.
If you are using the validation rules property, you can catch validation and duplicate key errors, amongst other things, in the Form Error event:
Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr=2107 Then
MsgBox "Validation error! " & ActiveControl.Name
End If
End Sub
You can enforce the use of your close button with a variable defined at form level and set to false unless your button is clicked.
Option Compare Database
Option Explicit
Public AllowClose As Boolean
Private Sub Form_Load()
AllowClose = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Cancel = Not AllowClose
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
AllowClose = True
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub
From: http://www.tek-tips.com/faqs.cfm?fid=2071
If you give us an example of one of your validation rules, it might help.
However, I've been under the habit of putting validation in Before Update (especially when I've got more complex validation algorithms)
Update:
I did some experimentation and it seems that the validation rule for the field is ONLY checked when you make an update to the field, but not if you are making an update somewhere else on the form, and not when you save the record. So I think your solution is to move validation to Form_BeforeUpdate.
OR you could make the column in the table non-null - which would force the users do something with the field.
OR, if the field must be "Testing", then you could side step the whole thing by setting a default value and locking the field so the user can't change it.
You can hide the navigation buttons by setting the form's Navigation Buttons property to "No." You can also disallow tabbing to a new record by setting the form's Cycle property to "Current Record."
With any nontrival application interface in Access, I usually lock the form down pretty tight and supply my own nav buttons, close button, etc. as needed.