![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
Ads |
#2
|
|||
|
|||
![]() Why do you know that no error occurs? BTW, in AddBCC you must declare the Cancel argument as ByRef, else it won't be passed back. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Tue, 2 Jan 2007 11:08:51 +0800 schrieb Lanceford: I am having problems with VBA scripts sometimes failing to run. I have a script to send BCC's on all emails, however sometimes it fails to run, sometimes it runs fine. When it fails to run, there is no error message. I have noticed that when the scripts fail to run, it does so for for an entire period of time. I have not been able to recreate the scripts failing to execute, however if I look in the account that messages are BCC'd to I can see that for 24 hours here and for 3 hours there the script failed to execute. I don't think the problem is with the script, however here is the script. Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Call AddBCC(Item, Cancel, ) End Sub Private Sub AddBCC(ByVal Item As Object, ByVal Cancel As Boolean, strBcc As String) Dim objRecip As Recipient Dim strMsg As String Dim res As Integer On Error Resume Next Set objRecip = Item.Recipients.Add(strBcc) ' handle case of user canceling Outlook security dialog If Err = 287 Then strMsg = "Could not add a Bcc recipient " & _ "because the user said No to the security prompt." & _ " Do you want still to send the message?" res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _ "Security Prompt Cancelled") If res = vbNo Then Cancel = True Else objRecip.Delete End If Err.Clear Else objRecip.Type = olBCC objRecip.Resolve If Not objRecip.Resolved Then strMsg = "Could not resolve the Bcc recipient. " & _ "Do you want still to send the message?" res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _ "Could Not Resolve Bcc Recipient") If res = vbNo Then Cancel = True End If End If End If Set objRecip = Nothing End Sub |
#3
|
|||
|
|||
![]()
BTW, in AddBCC you must declare the
Cancel argument as ByRef, else it won't be passed back. How do I do this? Thanks. |
#4
|
|||
|
|||
![]() In VB you can simply delete the 'ByVal'. You can (but don't have to) replace it by 'ByRef'. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Keep your Outlook categories organized! http://www.shareit.com/product.html?...4&languageid=1 (German: http://www.VBOffice.net/product.html?pub=6) Am Tue, 2 Jan 2007 17:51:13 +0800 schrieb Lanceford: BTW, in AddBCC you must declare the Cancel argument as ByRef, else it won't be passed back. How do I do this? Thanks. |
#5
|
|||
|
|||
![]()
Thanks.
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA-run-through stopping after abount 250 items | Allan | Outlook and VBA | 6 | September 26th 06 11:04 PM |
Run VBA code on receipt of e-mail | White Horse | Outlook and VBA | 2 | August 28th 06 09:51 PM |
VBA Scripts Do Not Show Up As "Custom Actions" | [email protected] | Outlook and VBA | 4 | April 26th 06 10:29 PM |
Run VBA Code from 'new mail message' on standard toolbar | Carmi | Outlook and VBA | 8 | March 31st 06 06:53 PM |
Message Rule Does Not Run VBA Procedure | Lowell | Outlook and VBA | 18 | March 9th 06 07:47 PM |