Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Form as Attachment

Status
Not open for further replies.

bw2601

Technical User
Dec 16, 2004
29
US
does anyone know how to send a form as an attachment using this code?

Option Compare Database

Sub sbSendMessage(Optional AttachmentPath)

Dim objOutlook As Outlook.Application
Dim objOutLookMsg As Outlook.MailItem
Dim objOutLookRecip As Outlook.Recipient
'Dim objOutlookAttach As Outlook.Attachment
Dim stDocName As String
Dim toField As String

On Error GoTo errmsgs

stDocName = "Email_Ticket"
'toField = (Form_HelpDesk!First_Name & " " & Form_HelpDesk!Last_Name)
toField = "Brandie Willis"
Set objOutlook = CreateObject("Outlook.Application")
Set objOutLookMsg = objOutlook.CreateItem(olMailItem)

With objOutLookMsg

'recipients
Set objOutLookRecip = .Recipients.Add(toField)
objOutLookRecip.Type = olTo
'Set objOutLookRecip = .Recipients.Add("me.First_Name, me.Last_Name")
'objOutLookRecip.Type = olBCC

'subject
.Subject = "IT STAFF Trouble Ticket"

'body
.Body = "The Attachment Contains the Details of your Trouble Ticket" & vbCrLf & vbCrLf

'attachmentas
'.Attachments.Add
'importance
.Importance = olImportanceHigh


'resolve recipient name
For Each objOutLookRecip In .Recipients
If objOutLookRecip.Resolve Then
objOutLookMsg.Display
End If

Next
.Send

End With

Set objOutLookMsg = Nothing
Set objOutlook = Nothing
Set objOutLookRecip = Nothing
Set objOutlookAttach = Nothing

errmsgs:
If Err.Number = "287" Then
MsgBox "You Clicked NO to the Outlook Security Warning. " & _
"Return the Procedure and Click YES to access e-mail" & _
"Address to Send Your Message." _
Or MsgBox(Err.Description, Err.HelpContext, Err.Number)

Else
'MsgBox "Your Message was successfully Sent"
MsgBox Err.Description, Err.Number, Err.HelpContext
End If
End Sub


sorry if it is so rough, i am still working out the kinks

any help would be awsome
thanks
 
Could you tell us what IS happening when you run this? Are you getting an error message? Have not gone through it line by line, but generally it looks OK. What exactly is the problem?

Gerry
 
OK, Actually everything in this code works ok, the problem i am having is trying to get an access form to attach. i have tried several things to reference the form, and every time i do i get an error message that says object required or it is an activeX action and i can't do it. so i guess what i am curious about is if you can attach an access form using this code, or do i have to use the SendObject command?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top