outlook forms scripts

G

Guest

hi,

I need some scripts to:

1. send the form when clicking an icon.
2. move from page to page by icon

I know how to create the icons but I don't know the scipts.

Thanks

Amir
 
S

Sue Mosher [MVP-Outlook]

By "icon," do you mean a command button control added to a custom page on the form? If so then:

1)

Function CommandButton1_Click()
Item.Send
End Function

2)

Function CommandButton2_Click()
Item.GetInspector.SetCurrentFormPage "page name"
End Function
 
G

Guest

thanks,

I created a form with some user fileds.

I want that the recipient will get it as text in the body and not as form.

I search and found some answers in this site but none was worked for me.

the one I tried was:

==================
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 = Eng.fName.Text ' this is one on the fileds....
Item.Body
.DeferredDeliveryTime = Item.DeferredDeliveryTime
.DeleteAfterSubmit = Item.DeleteAfterSubmit
.ExpiryTime = Item.ExpiryTime
.Importance = Item.Importance
.OriginatorDeliveryReportRequested = _
Item.OriginatorDeliveryReportRequested
.ReadReceiptRequested = _
Item.ReadReceiptRequested
.Subject = Item.Subject
MsgBox objMsg.Body
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
===================================
but the message was empty... only the subject was OK.

thanks

Amir.
 
G

Guest

I can't edit the post so i'll try this:

I can define some vars to contein my text as i need it.

exmp:

=====
sub show_click()
Dim objInsp 'As Object
Set objControls = Item.GetInspector.ModifiedFormPages("Message").Controls
Set line1 = objControls("HebFName")
MsgBox line1
set line2 = objControls("Heb.lName")
MsgBox line2
Set objInsp = Nothing
end sub
======
but how can I join both line1 and line2 and make it as the body???

thanks....

Amir
 
S

Sue Mosher [MVP-Outlook]

To join two strings together, use the & concatenaton character:

strBody = line1.Value & " " & line2.Value

THen use strBody to set the value of the message's Body property.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
G

Guest

thanks for your answer...
I have a nother one.

I used the folowing code (some from you and some from someone else) to send
my plain form...

at the send command it gives you a message box that email was send and you
can close the original mail.

Is there any way to close it automaticly??

thanks

amir

=========== the code I used =========
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
Set objControls = Item.GetInspector.ModifiedFormPages("Message").Controls
Set line1 = objControls("HebFName")
strBody = strBody & vbCrLf & " Hebrew First Name: " & line1
set line2 = objControls("Heb.lName")
strBody = strBody & vbCrLf & " Hebrew Last Name: " & line2
set line3 = objControls("Eng.fName")
strBody = strBody & vbCrLf & " English First Name: " & line3
set line4 = objControls("Eng.lName")
strBody = strBody & vbCrLf & " English Last Name: " & line4
set line5 = objControls("JobTitle")
strBody = strBody & vbCrLf & " Job Title: " & line5
set line6 = objControls("telnum")
strBody = strBody & vbCrLf & " Phone: " & line6
set line7 = objControls("dirmanager")
strBody = strBody & vbCrLf & " Direct Manager: " & line7
set line8 = objControls("pernotes")
strBody = strBody & vbCrLf & " Notes: " & line8
.BodyFormat = olFormatPlain
.Body = strBody
.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

========== end of code ==============
 
S

Sue Mosher [MVP-Outlook]

In Outlook 2000, you can call Item.Close 1 to close and discard the current item. It will probably give you errors in Outook 2003, though, because of a bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top