Prompt to add for text to existing subject line before sending.

Status
Not open for further replies.

sgtdozerh

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
I currently have a prompt asking me if I want to bcc a set address when I send a message. My issue is if I answer yes, i want it to prompt me to enter alpha - numeric that will be added to the end of the existing subject line, then complete the send process.

Any ideas?

Current BCC code.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim objRecip As Recipient

Dim strMsg As String

Dim res As Integer

Dim strBcc As String

On Error Resume Next

strBcc = "email address here"

res = MsgBox("BCC this message to DNA Issues?", vbYesNo + vbDefaultButton1, _

"BCC Message")

If res = vbNo Then

Cancel = False

Else

Set objRecip = Item.Recipients.Add(strBcc)

objRecip.Type = olBCC

If Not objRecip.Resolve Then

strMsg = "Could not resolve the Bcc recipient. " & _

"Please check the BCC Script configuration. " & _

"Do you want still to send the message?"

res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _

"Could not resolve BCC")

If res = vbNo Then

Cancel = True

End If

End If

End If

Set objRecip = Nothing

End Sub

2013-01-25 13-28-19_Test - Message (HTML).png

Add to subject prompt.

Send.jpg

Thanks!

Jeremy
 
I have been playing with this for over an hour and can't get it to work. i am trying the modification of the code to allow it to only apply to the active message. Any extra guidance you could provide?
 
Here is the updated code. I do get error's. I replaced the GetCurrent with Set objItem = objApp.ActiveInspector.CurrentItem since I only want it on the active email.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)

Dim objRecip As Recipient

Dim strMsg As String

Dim res As Integer

Dim strBcc As String

On Error Resume Next

strBcc = "dna@issues.dealer.com"

res = MsgBox("BCC this message to DNA Issues?", vbYesNo + vbDefaultButton1, _

"BCC Message")

If res = vbNo Then

Cancel = False

Else

Set objRecip = Item.Recipients.Add(strBcc)

objRecip.Type = olBCC

Sub AddFileNumber()

Dim aItem As Object

' Don't forget the function

Set objItem = objApp.ActiveInspector.CurrentItem

Dim iItemsUpdated As Integer

Dim strTemp As String

Dim strFilenum As Variant


' removed the loop so it only works with the selected item

strFilenum = InputBox("Enter the file number")

' Empty value or cancel button

If strFilenum = False Then Exit Sub

If strFilenum = "" Then Exit Sub

strTemp = "[" & strFilenum & "] " & aItem.Subject
aItem.Subject = strTemp
aItem.Save

If Not objRecip.Resolve Then

strMsg = "Could not resolve the Bcc recipient. " & _

"Please check the BCC Script configuration. " & _

"Do you want still to send the message?"

res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _

"Could not resolve BCC")

If res = vbNo Then

Cancel = True

End If

End If

End If

Set objRecip = Nothing

End Sub
 
Here is the updated code. I do get error's. I replaced the GetCurrent with Set objItem = objApp.ActiveInspector.CurrentItem since I only want it on the active email.

That was a duh! moment on my part - of course, with itemsend, its only going to be on the active mail. :) You don't even need that line in the code - you aren't using it (or at least, you shouldn't be using it.) You reference the item you are sending as Item.
 
This works for me -

I did two things - removed Sub AddFileNumber() and the set objitem lines. changed aItem to Item. When we "talk" about the message, we need to always refer to it by the same name. We use Item As Object in the beginning and need to stick with it. :)

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
strBcc = "me@domain.com"
res = MsgBox("BCC this message to DNA Issues?", vbYesNo + vbDefaultButton1, _
"BCC Message")
If res = vbNo Then
Cancel = False
Else
Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
Dim strTemp As String
Dim strFilenum As Variant
strFilenum = InputBox("Enter the file number")
If strFilenum = False Then Exit Sub
If strFilenum = "" Then Exit Sub
strTemp = "[" & strFilenum & "] " & Item.Subject
Item.Subject = strTemp
Item.Save
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Please check the BCC Script configuration. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could not resolve BCC")
If res = vbNo Then
Cancel = True
End If
End If
End If
End Sub
 
Diane - The prompt is working, but does not add the entry to the subject line. If entry is null or cancel is selected I get the following error and my message is not sent. I also wanted to thank you for all your help.

Error.png
 
Ah, i only tested yes and no.

Try this - i rearranged the order of the lines and added an IF Then statement so 1) the [] are not added if you cancel and 2) so it doesn't send if no # or that dialog is cancelled. You were exiting the sub if the field was blank rather than cancelling the send and Outlook didn't know what to do.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim objRecip As Recipient
Dim strMsg As String
Dim res As Integer
Dim strBcc As String
On Error Resume Next
strBcc = "me@domain.com"
res = MsgBox("BCC this message to DNA Issues?", vbYesNo + vbDefaultButton1, _
"BCC Message")
If res = vbNo Then
Cancel = False
Else
Dim strTemp As String
Dim strFilenum As Variant
strFilenum = InputBox("Enter the file number")
If strFilenum = "" Then
Cancel = True
MsgBox "The file number was blank or you clicked Cancel." _
& vbCrLf & "click Send and select No if you don't want to BCC & add a file number."
Exit Sub

Else
strTemp = "[" & strFilenum & "] " & Item.Subject
Item.Subject = strTemp
Item.Save
End If

Set objRecip = Item.Recipients.Add(strBcc)
objRecip.Type = olBCC
If Not objRecip.Resolve Then
strMsg = "Could not resolve the Bcc recipient. " & _
"Please check the BCC Script configuration. " & _
"Do you want still to send the message?"
res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
"Could not resolve BCC")
If res = vbNo Then
Cancel = True
End If
End If
End If
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Outlook security prompt after installing Add-in Outlook VBA and Custom Forms 3
B Requesting VBA code to make Outlook prompt for confirmation when deleting a task? Outlook VBA and Custom Forms 4
C How to fix outlook continuing to prompt fo an Exchange password Using Outlook 0
D Prompt to prefix subject line whenever sending an email Outlook VBA and Custom Forms 3
Paul Hobbs Automatically accept "Empty Folders" prompt Outlook VBA and Custom Forms 6
C VBA to prompt for Sent folder destination Outlook VBA and Custom Forms 3
Q Prompt button to auto turn on Out of Office Outlook VBA and Custom Forms 3
R Prompt asking the user to send email to folder as *.msg file Outlook VBA and Custom Forms 1
R Make Enter Network Password Prompt Go Away Automatically Using Outlook 0
K VBA to prompt and send a CC Outlook VBA and Custom Forms 6
K VBA - Prompt for reminder date time Outlook VBA and Custom Forms 7
S Have Rule or Quick Step PROMPT for custom FLAG Due/Reminder date Outlook VBA and Custom Forms 3
P Constant Username Password Prompt Using Outlook 2
A Prompt on exit to empty deleted items folder "for all accounts" does not work? Using Outlook 6
C Is there a way to prompt a user before deleting an item? BCM (Business Contact Manager) 4
S Trying to have a prompt to ask for text to be added to subject before sending. Using Outlook 3
N Prompt for password when sending an email Exchange Server Administration 1
O How to turn off the prompt to permanently delete messages upon exiting? Using Outlook 2
M Email Prompt Outlook VBA and Custom Forms 1
T Prompt for email account Outlook VBA and Custom Forms 1
Q Otlk 2007 does not block when in "always prompt for..." mode Outlook VBA and Custom Forms 2
Q sending mail when Otlook in 'always prompt for user name and passw Outlook VBA and Custom Forms 4
G Add Map It button to Custom Contacts Form in Outlook Outlook VBA and Custom Forms 1
G Outlook 2021 Add Picture to Custom Contact Form Outlook VBA and Custom Forms 2
P Can't add custom field to custom Outlook form, it always adds to the Folder instead Outlook VBA and Custom Forms 2
P VBA to add email address to Outlook 365 rule Outlook VBA and Custom Forms 0
S Outlook 2019 Custom outlook Add-in using Visual Studio Outlook VBA and Custom Forms 0
G automatically choosing "add to autocorrect" option Using Outlook 0
F Want to add second email to Outlook for business use Using Outlook 4
K Add an entry to a specific calendar Using Outlook 1
F Add a category before "Send an Email When You Add an Appointment to Your Calendar" Outlook VBA and Custom Forms 0
J Want to create a button on the nav bar (module add-in) to run code Outlook VBA and Custom Forms 2
M "Attachment Detacher for Outlook" add in, does it update the server copy of the email? Using Outlook 1
J Outlook 365 Add keywords from Listbox to the message body where cursor is placed Outlook VBA and Custom Forms 0
O Add Day Number of the year for 2023-2033 Outlook VBA and Custom Forms 5
J GoDaddy migrated to Office365 - Outlook Wont Add Account Exchange Server Administration 21
F Outlook 2019 Outlook 2019 Add and Sync to New computer Comcast server Using Outlook 2
Witzker Add a text line at the end of the note field in all selected Contacts Outlook VBA and Custom Forms 7
A iCloud Outlook Add In is causing Outlook 2021 to crash and got disabled Using Outlook 10
N How to add or delete items to Move dropdown Menu Using Outlook 0
G Add contacts birthday to calendar Using Outlook 4
V How to add 'Previous Item' and 'Next Item' to the Quick Access Toolbar Using Outlook 1
Commodore Safe way to add or update holidays; Windows Notifications issue Using Outlook 8
kkqq1122 How would I add Search for attachment name Outlook VBA and Custom Forms 3
L did MS ever add way to text via Outlook Using Outlook 5
P How to add a column named categories when searching in Outlook Using Outlook 0
M add new attendee to existing meetings with VBA Outlook VBA and Custom Forms 5
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
Witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
P Add inanimate objects to meetings? Using Outlook 1

Similar threads

Back
Top