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.
Thread starter Similar threads Forum Replies Date
S How to add multiple exchange accounts without password / credential prompt? Using Outlook 5
P Outlook security prompt after installing Add-in 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
G Outlook keep prompt for log in credential Using Outlook 1
J Deactivate MS Outlook 2007 prompt to make it the default email client Using Outlook 1
O Outlook 2007 SP2 Prompt for Password Exchange Server Administration 3
R Does not prompt for saving or opening attachments when downloading attachment in Outlook 2007. Using Outlook 3
S Continuous password and username prompt in outlook 2007 Using Outlook 1
E Enter Network Password prompt does not accept my password Using Outlook 4
I Prompt before sending contacts to Deleted Items folder Using Outlook 7
B Password prompt for the pst files Using Outlook 9
O OWA 2003 prompt to re-auntenticate when opening up office attachments Using Outlook 10
L outlook 2007 login prompt from old exchange host Using Outlook 3
B outlook 2007 password prompt keeps popping up Using Outlook 1
M Outlook 2007 and Outlook 2010 continues to prompt user for their password Using Outlook 7
E Users get login prompt in Outlook 2007 when accessing Exchange Server 2007 Using Outlook 2
D Credentials Prompt Exchange Server Administration 1
L Strange macro prompt Using Outlook 1
C outlook clients prompt for a password each time it open Exchange Server Administration 2
S exchange 2010 e-mail user password expiration prompt Exchange Server Administration 8
S After installing 3rd party Certificate for IIS , prompt warning for mapi clients the name on security certificate is invalid , Exchange Server Administration 3
S cross post please read: Exchange Account password prompt in Outlook 2010 Using Outlook 2
T Outlook 2010 Setting to Prompt 'Send before Exiting'__ Using Outlook 2
J Enable prompt to save/open attachment Using Outlook 1
C Reboot a CAS array member causes Outlook 2010 clients to prompt for credentials. Using Outlook 5
O Password Prompt in Outlook 2003 Using Outlook 4
S cannot get past OWA login prompt Using Outlook 4
J Outlook 2003 Calendar Meeting NO Cancellation Prompt Using Outlook 1
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
J Outlook 2007 Clients Prompt For Password When Opening Using Outlook 21
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
B 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
Similar threads


















































Top