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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange

sgtdozerh

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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?
 

sgtdozerh

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
 

sgtdozerh

Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
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
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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
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
M add new attendee to existing meetings with VBA Outlook VBA and Custom Forms 1
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
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
BartH Add a string to the conditions in .Conditions.BodyOrSubject.Text Outlook VBA and Custom Forms 2
A "Get Add-Ins" - Which Version of Outlook to use Using Outlook 1
D Do I need Exchange Add-In? Using Outlook 6
C-S-R Manage Add-ins (Remove Wunderlist) Using Outlook 6
A iCloud add in problems Using Outlook 4
L Macro to add Date & Time etc to "drag to save" e-mails Outlook VBA and Custom Forms 8
C Looking for feedback on new Outlook Add-in Using Outlook 0
L isn't there an OL add-on that flags addressee before sending Using Outlook 3
S Add VBA save code Using Outlook 0
P Shortcut Pane - add shortcut to Office365 group mailbox Using Outlook 1
Z Add ComboBox Value to Body of Email Outlook VBA and Custom Forms 1
G How to add a folder shortcut to outlook quick access toolbar? Using Outlook 6
G Add to Outlook Contacts - Point to non-default contacts folder Using Outlook 0
M Automatically add senders first name to a greeting Outlook VBA and Custom Forms 1
C Add Form to Appointments Received, Automatically Outlook VBA and Custom Forms 6
O Outlook tasks - Add text column with multiple lines Using Outlook 3
W April 2020 Office 365 Update - Add-Ons fail after Office 365 Update Using Outlook 6
Z Task Filter Not Working When I add too many criteria Using Outlook 0
D Add date next to day name in Outlook Today calendar view Using Outlook 1
D iCloud Add-in not working in Outlook 2013 and Outlook 2016 After Windows Upgrade & iCloud Upgrade Using Outlook 2
P Add Paste Unformatted to QAT Using Outlook 1
M Ignore slow add-ins Using Outlook 0
B Add Prefix text to Subject Line Using Outlook 1
Jennifer Murphy Add birthdays to calendar Using Outlook 7
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4
P Add, remove, & reorder folder pane Using Outlook 6

Similar threads

Top