add attachment to post form OL2K3

Joined
May 29, 2007
Messages
2
Reaction score
0
I need to be able to add attachments, whether from the local drive, network drive, or document management system. I have a post form that sends a plain text message to a helpdesk ticketing system, and I need to be able to open the attachments there, or anywhere. I'm not sure what to do with the following code:

Const olByValue = 1
objForward.Attachments.Add "C:\my file.doc", olByValue

...or where to put it in the code for my form:

'*****************************************************
'
'Computer-Support Request Form
'
'*****************************************************


Dim m_blnUserSent
Const olDiscard = 1

Function Item_Write()
MsgBox "This form cannot be saved. " & _
"Please select No when asked to save " & _
"to close this form once you have " & _
"completed your request. You will recieve " & _
"a ticket number, which confirms that your " & _
"request has been received."
Item_Write = False
End Function

Function Item_Close ()
Dim intRes
Dim strMsg
If Not M_blnUserSent Then
strMsg = "You have not yet sent this request. " & _
"Do you really want to discard it?"
intRes = MsgBox (strMsg, vbYesNo + vbQuestion, _
"Abandon Request")
If intRes = vbNo Then
Item_Close = False
Else
Item.Close olDiscard
End if
End If
End Function

Sub cmdSubmit_Click ()
Dim strDetails
Dim objForward
On Error Resume Next
strDetails = Item.Body
Item.BodyFormat = 1
strBody = AddLine ("Subject") & _
AddLine ("Locations") & _
AddLine ("Dept.") & _
AddLine ("Phone Number") & _
AddLine ("Cat") & _
AddLine ("Product") & _
AddLine ("Symptoms") & _
AddLine ("Priorities")
If strDetails <> "" Then
strBody = strBody & vbCrLf & strDetails
End If
Set objForward = Item.Forward
objForward.Body = strBody

vMessage = ": " & CRLF
missingData = False

If ValidateField ("Subject") = False Then
vMessage = vMessage & "Subject " & CRLF
missingData = True
End If

If ValidateField ("Locations") = False Then
vMessage = vMessage & "Location " & CRLF
missingData = True
End If

If ValidateField ("Dept.") = False Then
vMessage = vMessage & "Department " & CRLF
missingData = True
End If

If ValidateField ("Phone Number") = False Then
vMessage = vMessage & "Telephone Number " & CRLF
missingData = True
End If

If ValidateField ("Cat") = False Then
vMessage = vMessage & "Category " & CRLF
missingData = True
End If

If ValidateField ("Product") = False Then
vMessage = vMessage & "Product " & CRLF
missingData = True
End If

If ValidateField ("Symptoms") = False Then
vMessage = vMessage & "Symptom " & CRLF
missingData = True
End If

If missingData = True Then
Err.Raise vbObjectError+2048
Else
objForward.Send
End If

If Err = 0 Then
m_blnUserSent = True
msgBox "Request has been submitted. If this " & _
"issue is not addressed in a timely manner, it " & _
"will be automatically escalated. Please " & _
"do not re-submit this request." , , _
"Computer Support Request"
ElseIf Err = vbObjectError+2048 Then
MsgBox "The following fields must be populated" & CRLF & vMessage , , _
"Computer Support Request"
Else
MsgBox "Request has not been submitted. Error occurred." & Err.Description, , _
"Computer Support Request"
End If

Err.Clear

Item.Close olDiscard
End Sub

Function ValidateField(strProp)
Dim objProp
On Error Resume Next
Set objProp = Item.UserProperties (strProp)

If objProp.Value <> "" Then
ValidateField = True
Else
ValidateField = False
End If
Err.Clear
End Function

Function AddLine (strProp)
Dim objProp
Dim strLine
On Error Resume Next
Set objProp = Item.UserProperties (strProp)
strLine = strProp & ": "
If Not objProp Is Nothing Then
strLine = strLine & objProp.Value
Else
strLine = strLine & "Property not available"
End If
AddLine = strLine & vbCrLf
End Function
 

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