At the end of my form, the user presses a button that activates the SendMail method sending the workbook to us. I'd like them to also be able to send an attachment Zip file with the document.
I know it can be done using a code similar to this:
Sub email(subject)
' requires a reference to the Microsoft Outlook 8.0 Object Library
' creates and sends a new e-mail message with Outlook
Dim OLF As Outlook.MAPIFolder, olMailItem As Outlook.MailItem
Dim ToContact As Outlook.Recipient
Set OLF = GetObject("", _
"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set olMailItem = OLF.Items.Add ' creates a new e-mail message
With olMailItem
.subject = subject ' message subject
On Error Resume Next
Set ToContact = .Recipients.Add(Range("B8").Value) ' add a recipient
Set ToContact = .Recipients.Add(Range("e48").Value) ' add a recipient
Set ToContact = .Recipients.Add(Range("e50").Value) ' add a recipient
Set ToContact = .Recipients.Add(Range("e52").Value) ' add a recipient
Set ToContact = .Recipients.Add(Range("e54").Value) ' add a recipient
Set ToContact = .Recipients.Add(Range("e56").Value) ' add a recipient
Set ToContact = .Recipients.Add(Range("e58").Value) ' add a recipient
.body = "This message is to notify you on the start of the project titled: " & subject & vbCrLf _
& "Assigned to: " & Range("e48").Value & vbCrLf _
& "Due by: " & Range("e34").Value & " " & Range("b34").Value & vbCrLf _
& "Requested by: " & Range("b4").Value & " for: " & Range("b10").Value & vbCrLf _
& "Customer Account Number: " & Range("e10").Value & vbCrLf _
& "Customer Estimate: " & Range("b37").Value & vbCrLf _
& "Customer Price Limit: " & Range("e37").Value & vbCrLf _
& "Other Information: " & Range("h1").Value & vbCrLf _
& Range("h3").Value & vbCrLf _
& Range("h5").Value & vbCrLf _
& Range("h7").Value
' the message text with a line break
.OriginatorDeliveryReportRequested = False ' delivery confirmation
.ReadReceiptRequested = False ' read confirmation
.Send ' sends the e-mail message (puts it in the Outbox)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
Set OLF = Nothing
End Sub
However said code requires a reference to Outlook which causes problems depending on what system it is being filled out on.
Are there any other methods availible to send attachments that require program referances?
Bookmarks