G
Guest
Hi there, i am currently in the process of testing/building a new contact
management system based on access forms - i have an email form that users
fill in and then click on an email button to send the contents of the form to
the required contact automatically via access. However as part of filling in
the form i need users to be able to click on a button that will open a browse
button that will allow them to select a single or multiple attachments to the
form and then clicking on the email button will allow them to send the
contents of the form via outlook, which will then obviously include the
attachment(s). these attachments would then have the path to them stored in
a filed in the email back end table.
Does anyone have any code for doing this? This is my current code for
sending the contents of the form via outlook:
Public Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim strAddress As String
Dim strMsg As String
Dim strTitle As String
Dim strSent As Integer
Dim objOutlookAttach As Outlook.Attachment
DoCmd.RunCommand acCmdSaveRecord
strMsg = Forms!email!body
strAddress = Forms!email!emailaddress
strTitle = Forms!email!subject
strSent = Forms!email!sent
If Forms!email!sent = True Then
MsgBox "This email has already been sent", vbInformation, "Notification"
DoCmd.Close
Else
DoCmd.SendObject , , acFormatHTML, strAddress, , , strTitle, strMsg,
False, False
'Run update to update the sent mail check box
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE email SET email.sent = -1"
DoCmd.SetWarnings True
MsgBox "Email has been sent", vbInformation, "Thank You"
DoCmd.Close
End If
exit_command5_click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume exit_command5_click
End Sub
Thanks,
Rhys.
management system based on access forms - i have an email form that users
fill in and then click on an email button to send the contents of the form to
the required contact automatically via access. However as part of filling in
the form i need users to be able to click on a button that will open a browse
button that will allow them to select a single or multiple attachments to the
form and then clicking on the email button will allow them to send the
contents of the form via outlook, which will then obviously include the
attachment(s). these attachments would then have the path to them stored in
a filed in the email back end table.
Does anyone have any code for doing this? This is my current code for
sending the contents of the form via outlook:
Public Sub Command5_Click()
On Error GoTo Err_Command5_Click
Dim strAddress As String
Dim strMsg As String
Dim strTitle As String
Dim strSent As Integer
Dim objOutlookAttach As Outlook.Attachment
DoCmd.RunCommand acCmdSaveRecord
strMsg = Forms!email!body
strAddress = Forms!email!emailaddress
strTitle = Forms!email!subject
strSent = Forms!email!sent
If Forms!email!sent = True Then
MsgBox "This email has already been sent", vbInformation, "Notification"
DoCmd.Close
Else
DoCmd.SendObject , , acFormatHTML, strAddress, , , strTitle, strMsg,
False, False
'Run update to update the sent mail check box
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE email SET email.sent = -1"
DoCmd.SetWarnings True
MsgBox "Email has been sent", vbInformation, "Thank You"
DoCmd.Close
End If
exit_command5_click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume exit_command5_click
End Sub
Thanks,
Rhys.