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 - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , , ,

Item_Send: How to generate a non-custom form message from custom f





 
 
Thread Tools Display Modes
  #1  
Old April 9th 07, 08:40 PM posted to microsoft.public.outlook.program_forms
supportusa
external usenet poster
 
Posts: 2
Default Item_Send: How to generate a non-custom form message from custom f

I noticed a brief reference in a previous posting about using code in a
custom form's Item_Send event handler to generate a new, non-custom-form
message. I need to do exactly this. How can I accomplish this? I am
relatively new to VBA in Outlook, so treat me as a novice. Thank you!
Ads
  #2  
Old April 9th 07, 09:31 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Item_Send: How to generate a non-custom form message from custom f

It would be VBScript code, not VBA, because that's what Outlook custom forms use, and would look something like this, to create a new plain text message. Note that you need to add CopyAtts subroutine from http://www.outlookcode.com/d/code/copyatts.htm to this script.

Function Item_Send()
Dim objMsg ' As Outlook.MailItem
Dim objRecip ' As Outlook.Recipient
Dim objNewRecip ' As Outlook.Recipient
Const olMailItem = 0
Const olFormatPlain = 1
On Error Resume Next
Item_Send = False
Set objMsg = Application.CreateItem(olMailItem)
For Each objRecip In Item.Recipients
Set objNewRecip = _
objMsg.Recipients.Add(objRecip.address)
If objNewRecip.Resolve Then
objNewRecip.Type = objRecip.Type
End If
Next
If Item.Attachments.Count 0 Then
' Add CopyAtts function from
' http://www.outlookcode.com/d/code/copyatts.htm
' to this script.
Call CopyAtts(Item, objMsg)
End If
With objMsg
.BodyFormat = olFormatPlain
.Body = Item.Body
.DeferredDeliveryTime = Item.DeferredDeliveryTime
.DeleteAfterSubmit = Item.DeleteAfterSubmit
.ExpiryTime = Item.ExpiryTime
.Importance = Item.Importance
.OriginatorDeliveryReportRequested = _
Item.OriginatorDeliveryReportRequested
.ReadReceiptRequested = _
Item.ReadReceiptRequested
.Subject = Item.Subject
If .Recipients.count 0 _
And .Recipients.ResolveAll Then
.Send
MsgBox "Message sent successfully. " & _
"You can close the original now."
Else
.Display
End If
End With
Set objMsg = Nothing
Set objRecip = Nothing
Set objNewRecip = Nothing
End Function

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"supportusa" wrote in message ...
I noticed a brief reference in a previous posting about using code in a
custom form's Item_Send event handler to generate a new, non-custom-form
message. I need to do exactly this. How can I accomplish this? I am
relatively new to VBA in Outlook, so treat me as a novice. Thank you!

  #3  
Old April 9th 07, 10:00 PM posted to microsoft.public.outlook.program_forms
supportusa
external usenet poster
 
Posts: 2
Default Item_Send: How to generate a non-custom form message from cust

Thank you, Sue. I ran this code in a custom form (without the CopyAtts
subroutine), and it appeared to run. I got the successful message at the end
of the script. However, the message that was received on the other end was
blank. Do I need to customize any of the script? I just ran it as it is.


"Sue Mosher [MVP-Outlook]" wrote:

It would be VBScript code, not VBA, because that's what Outlook custom forms use, and would look something like this, to create a new plain text message. Note that you need to add CopyAtts subroutine from http://www.outlookcode.com/d/code/copyatts.htm to this script.

Function Item_Send()
Dim objMsg ' As Outlook.MailItem
Dim objRecip ' As Outlook.Recipient
Dim objNewRecip ' As Outlook.Recipient
Const olMailItem = 0
Const olFormatPlain = 1
On Error Resume Next
Item_Send = False
Set objMsg = Application.CreateItem(olMailItem)
For Each objRecip In Item.Recipients
Set objNewRecip = _
objMsg.Recipients.Add(objRecip.address)
If objNewRecip.Resolve Then
objNewRecip.Type = objRecip.Type
End If
Next
If Item.Attachments.Count 0 Then
' Add CopyAtts function from
' http://www.outlookcode.com/d/code/copyatts.htm
' to this script.
Call CopyAtts(Item, objMsg)
End If
With objMsg
.BodyFormat = olFormatPlain
.Body = Item.Body
.DeferredDeliveryTime = Item.DeferredDeliveryTime
.DeleteAfterSubmit = Item.DeleteAfterSubmit
.ExpiryTime = Item.ExpiryTime
.Importance = Item.Importance
.OriginatorDeliveryReportRequested = _
Item.OriginatorDeliveryReportRequested
.ReadReceiptRequested = _
Item.ReadReceiptRequested
.Subject = Item.Subject
If .Recipients.count 0 _
And .Recipients.ResolveAll Then
.Send
MsgBox "Message sent successfully. " & _
"You can close the original now."
Else
.Display
End If
End With
Set objMsg = Nothing
Set objRecip = Nothing
Set objNewRecip = Nothing
End Function

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"supportusa" wrote in message ...
I noticed a brief reference in a previous posting about using code in a
custom form's Item_Send event handler to generate a new, non-custom-form
message. I need to do exactly this. How can I accomplish this? I am
relatively new to VBA in Outlook, so treat me as a novice. Thank you!


  #4  
Old April 9th 07, 11:37 PM posted to microsoft.public.outlook.program_forms
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Item_Send: How to generate a non-custom form message from cust

After the code sets the Body property, you might want to throw in a MsgBox objMsg.Body statement to see what Outlook thinks the new message body contains. Also make sure you're up-to-date on Outlook patches, since there have been some blank message issues in some versions.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx

"supportusa" wrote in message ...
Thank you, Sue. I ran this code in a custom form (without the CopyAtts
subroutine), and it appeared to run. I got the successful message at the end
of the script. However, the message that was received on the other end was
blank. Do I need to customize any of the script? I just ran it as it is.


"Sue Mosher [MVP-Outlook]" wrote:

It would be VBScript code, not VBA, because that's what Outlook custom forms use, and would look something like this, to create a new plain text message. Note that you need to add CopyAtts subroutine from http://www.outlookcode.com/d/code/copyatts.htm to this script.

Function Item_Send()
Dim objMsg ' As Outlook.MailItem
Dim objRecip ' As Outlook.Recipient
Dim objNewRecip ' As Outlook.Recipient
Const olMailItem = 0
Const olFormatPlain = 1
On Error Resume Next
Item_Send = False
Set objMsg = Application.CreateItem(olMailItem)
For Each objRecip In Item.Recipients
Set objNewRecip = _
objMsg.Recipients.Add(objRecip.address)
If objNewRecip.Resolve Then
objNewRecip.Type = objRecip.Type
End If
Next
If Item.Attachments.Count 0 Then
' Add CopyAtts function from
' http://www.outlookcode.com/d/code/copyatts.htm
' to this script.
Call CopyAtts(Item, objMsg)
End If
With objMsg
.BodyFormat = olFormatPlain
.Body = Item.Body
.DeferredDeliveryTime = Item.DeferredDeliveryTime
.DeleteAfterSubmit = Item.DeleteAfterSubmit
.ExpiryTime = Item.ExpiryTime
.Importance = Item.Importance
.OriginatorDeliveryReportRequested = _
Item.OriginatorDeliveryReportRequested
.ReadReceiptRequested = _
Item.ReadReceiptRequested
.Subject = Item.Subject
If .Recipients.count 0 _
And .Recipients.ResolveAll Then
.Send
MsgBox "Message sent successfully. " & _
"You can close the original now."
Else
.Display
End If
End With
Set objMsg = Nothing
Set objRecip = Nothing
Set objNewRecip = Nothing
End Function

"supportusa" wrote in message ...
I noticed a brief reference in a previous posting about using code in a
custom form's Item_Send event handler to generate a new, non-custom-form
message. I need to do exactly this. How can I accomplish this? I am
relatively new to VBA in Outlook, so treat me as a novice. Thank you!


 




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
Custom Form - Receiver replies and form is gone, message body is b Kozlik Outlook - Using Forms 16 July 14th 06 10:32 PM
Emailing a contact vCard with custom form loses all custom info Kim Outlook - Using Contacts 7 April 27th 06 01:21 AM
How to add sender name to cc for Custom Message form in Outlook David Tallahassee Outlook - Using Forms 2 March 29th 06 09:27 PM
opening new custom Message form Melbin Outlook - Using Forms 2 January 24th 06 01:16 PM
Cannot programmatically open custom message in custom form ms Outlook - Using Forms 1 January 20th 06 04:01 PM


All times are GMT +1. The time now is 03:19 PM.


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.
Current Accounts - Personal Loans - Web Advertising - Mortgages - Nissan Armada Forum