A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , , ,

Outlook Macro to Modify Subject and Send Message





 
 
Thread Tools Display Modes
  #1  
Old September 25th 06, 10:50 PM posted to microsoft.public.outlook.program_vba
jaysonsch
external usenet poster
 
Posts: 3
Default Outlook Macro to Modify Subject and Send Message

Good afternoon,

I'd like to create a Macro for Outlook 2003 to modify the subject of a
message to prepend a given phase and send the message. I can't imagine
that this would be too hard of a task, unfortunately, I'm not sure
where to begin.

Can someone help me out here? If you have the solution, that's great.
But I'd really like some links to training docs also to familiarize
myself with Macros in Outlook.

Thanks!

Ads
  #2  
Old September 26th 06, 04:22 AM posted to microsoft.public.outlook.program_vba
jaysonsch
external usenet poster
 
Posts: 3
Default Outlook Macro to Modify Subject and Send Message

Through a bit of research, I found the code to create a button that
will append a phrase to a subject and then send the message using the
Send function of the olMailItem attribute. However, address resolution
seems to be a bit messy. Upon investigation, it seems that it would be
a lot nicer if I could just send the message by somehow invoking the
functionality of the Outlook Send button. Is this a possibility? If
not, is there some commonly used error handling code for this? Please
help!

jaysonsch wrote:
Good afternoon,

I'd like to create a Macro for Outlook 2003 to modify the subject of a
message to prepend a given phase and send the message. I can't imagine
that this would be too hard of a task, unfortunately, I'm not sure
where to begin.

Can someone help me out here? If you have the solution, that's great.
But I'd really like some links to training docs also to familiarize
myself with Macros in Outlook.

Thanks!


  #3  
Old September 26th 06, 05:50 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,196
Default Outlook Macro to Modify Subject and Send Message

Am 25 Sep 2006 20:22:34 -0700 schrieb jaysonsch:

Before callign the Send method you can call the MailItemīs
Recipients.ResolveAll function.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Through a bit of research, I found the code to create a button that
will append a phrase to a subject and then send the message using the
Send function of the olMailItem attribute. However, address resolution
seems to be a bit messy. Upon investigation, it seems that it would be
a lot nicer if I could just send the message by somehow invoking the
functionality of the Outlook Send button. Is this a possibility? If
not, is there some commonly used error handling code for this? Please
help!

jaysonsch wrote:
Good afternoon,

I'd like to create a Macro for Outlook 2003 to modify the subject of a
message to prepend a given phase and send the message. I can't imagine
that this would be too hard of a task, unfortunately, I'm not sure
where to begin.

Can someone help me out here? If you have the solution, that's great.
But I'd really like some links to training docs also to familiarize
myself with Macros in Outlook.

Thanks!

  #4  
Old September 26th 06, 03:15 PM posted to microsoft.public.outlook.program_vba
jaysonsch
external usenet poster
 
Posts: 3
Default Outlook Macro to Modify Subject and Send Message

Micheal,

Thanks for your help. What I put togehter can be found at the bottom
of this post. The one problem that I'm running into right now,
however, is that if I do the following...

- Compose a Message
- Enter a valid address in one of the address fields
- Resolve the address using Outlook's check name feature
- Remove the address and leave the address field blank
- Continue to compose the message
- Activate the Macro again

....my script then thinks that there is still a recipient even though
none appears in the TO, CC, or BCC fields. To validate this, I have
created a message box that shows these values. Am I checking the wrong
property to see if there is an addressee or is this a problem with
Outlook? I'm developing this on Outlook 2003 SP2.

Thanks!

------------------------------------------------------------------
CODE:



Public Sub Popup()
With Application.ActiveInspector
If TypeOf .CurrentItem Is Outlook.MailItem Then
'Validate that at least one recipient is
specified
If (.CurrentItem.To = "") And (.CurrentItem.CC
= "") And (.CurrentItem.BCC = "") Then
MsgBox "There must be at least one name
or distribution list in the TO, CC, or BCC box.", 48, "Error"
Else
'Resolve All Addresses
If Not
..CurrentItem.Recipients.ResolveAll Then
Set myRecipients =
..CurrentItem.Recipients

'Count Number of Recipients
Dim intCount As Integer
intCount = myRecipients.Count

'Determine Recipients that did not
resolve and echo in MsgBox
Dim strErrtxt As String
strErrtxt = "The addresses of the
following recipients could not be resolved:" & vbCrLf
For Each myRecipient In
myRecipients
If Not myRecipient.Resolved
Then
strErrtxt = strErrtxt &
vbCrLf & myRecipient.Name
End If
Next
strErrtxt = strErrtxt & vbCrLf &
vbCrLf & "Please use the ""Check Name"" feature from the Tools Menu to
validate the addresses specified."
MsgBox strErrtxt, vbExclamation,
"Error"
Else
'DEBUG: Echo that Resolve was OK
MsgBox "Resolve OK"

'
'The next few lines are commented
out to faciliate testing of the resolve functionallity
'
'.CurrentItem.Subject = "PREFIX: "
& .CurrentItem.Subject
'.CurrentItem.Send
End If
End If
'DEBUG: Display Fields
MsgBox "To: " & .CurrentItem.To & vbCrLf &
"CC: " & .CurrentItem.CC & vbCrLf & "BCC: " & .CurrentItem.BCC

End If
End With
End Sub

  #5  
Old September 27th 06, 05:48 AM posted to microsoft.public.outlook.program_vba
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,196
Default Outlook Macro to Modify Subject and Send Message

Am 26 Sep 2006 07:15:45 -0700 schrieb jaysonsch:

I donīt understand what the problem is and you do not "Remove the address
and leave the address field blank" as far as I can see.

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
-- www.VBOffice.net --


Micheal,

Thanks for your help. What I put togehter can be found at the bottom
of this post. The one problem that I'm running into right now,
however, is that if I do the following...

- Compose a Message
- Enter a valid address in one of the address fields
- Resolve the address using Outlook's check name feature
- Remove the address and leave the address field blank
- Continue to compose the message
- Activate the Macro again

...my script then thinks that there is still a recipient even though
none appears in the TO, CC, or BCC fields. To validate this, I have
created a message box that shows these values. Am I checking the wrong
property to see if there is an addressee or is this a problem with
Outlook? I'm developing this on Outlook 2003 SP2.

Thanks!

------------------------------------------------------------------
CODE:



Public Sub Popup()
With Application.ActiveInspector
If TypeOf .CurrentItem Is Outlook.MailItem Then
'Validate that at least one recipient is
specified
If (.CurrentItem.To = "") And (.CurrentItem.CC
= "") And (.CurrentItem.BCC = "") Then
MsgBox "There must be at least one name
or distribution list in the TO, CC, or BCC box.", 48, "Error"
Else
'Resolve All Addresses
If Not
.CurrentItem.Recipients.ResolveAll Then
Set myRecipients =
.CurrentItem.Recipients

'Count Number of Recipients
Dim intCount As Integer
intCount = myRecipients.Count

'Determine Recipients that did not
resolve and echo in MsgBox
Dim strErrtxt As String
strErrtxt = "The addresses of the
following recipients could not be resolved:" & vbCrLf
For Each myRecipient In
myRecipients
If Not myRecipient.Resolved
Then
strErrtxt = strErrtxt &
vbCrLf & myRecipient.Name
End If
Next
strErrtxt = strErrtxt & vbCrLf &
vbCrLf & "Please use the ""Check Name"" feature from the Tools Menu to
validate the addresses specified."
MsgBox strErrtxt, vbExclamation,
"Error"
Else
'DEBUG: Echo that Resolve was OK
MsgBox "Resolve OK"

'
'The next few lines are commented
out to faciliate testing of the resolve functionallity
'
'.CurrentItem.Subject = "PREFIX: "
& .CurrentItem.Subject
'.CurrentItem.Send
End If
End If
'DEBUG: Display Fields
MsgBox "To: " & .CurrentItem.To & vbCrLf &
"CC: " & .CurrentItem.CC & vbCrLf & "BCC: " & .CurrentItem.BCC

End If
End With
End Sub

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I modify the message field in an outlook form ? jackie Outlook - Using Forms 1 August 17th 06 11:07 PM
OL2003: Message List shows Message Size rather than Subject David Lipetz Outlook - General Queries 2 August 10th 06 10:29 PM
Modify the message form for reading in OL2007 lee Outlook - Using Forms 2 July 29th 06 06:01 AM
Macro to kick in every time I send a message Jyoti Outlook and VBA 5 May 27th 06 11:04 AM
Macro to prompt for metadata and them place in the subject line Ben Bazian Outlook and VBA 1 April 12th 06 06:19 AM


All times are GMT +1. The time now is 03:01 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright Đ2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Mortgage Calculator - Loans - Mortgage - FatCow Web hosting - Remortgage