This tip shows you how to send email attachments with in your VB program.

You will need 5 text boxes, 2 command buttons and the Common Dialog Control. They are as follows.

txtToAddresses
txtCCAddresses
txtBCCAddresses
txtSubject
txtBody - 'Make sure that MultiLIne is set to true
txtAttachmentLocation
cdbOpen 'The Common Dialog Control
cmdOpen - 'Opens the dialog box for file attachment
cmdSend

Now cut and past the code below.

  ==================================================
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, _
ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory _
As String, ByVal nShowCmd As Long) As Long

Private Const SW_SHOWNORMAL = 1

'For CCs (carbon copies): &CC= (followed by list)
'For blind CCs: &BCC= (followed by list)
'For subject text: &Subject= (followed by text)
'For body text: &Body= (followed by text)
'To add an attachment: &Attach= (followed by a valid file path within
'Chr (34) 's)

Private Sub cmdOpen_Click()

cdbOpen.ShowOpen
txtAttachmentLocation = cdbOpen.filename
End Sub

Private Sub cmdSendMail_Click()
Dim strMailInfo As String
Dim strAddedMailInfo As String

If Len(txtToAddresses) Then
strMailInfo = txtToAddresses
End If

If Len(txtCCAddresses) Then
strAddedMailInfo = strAddedMailInfo & "&CC=" & txtCCAddresses
End If

If Len(txtBCCAddresses) Then
strAddedMailInfo = strAddedMailInfo & "&BCC=" & txtBCCAddresses
End If

If Len(txtSubject) Then
strAddedMailInfo = strAddedMailInfo & "&Subject=" & txtSubject
End If

If Len(txtBody) Then
strAddedMailInfo = strAddedMailInfo & "&Body=" & txtBody 'txtMessageBody
End If

If Len(txtAttachmentLocation) Then
strAddedMailInfo = strAddedMailInfo & "&Attach=" & Chr(34) & _
txtAttachmentLocation & Chr(34)
End If

strMailInfo = "mailto:" & strMailInfo
' clean the added elements
If Len(strAddedMailInfo) <> 0 Then
' there are added elements, replace the first
' ampersand with the question character
Mid$(strAddedMailInfo, 1, 1) = "?"
End If

strMailInfo = strMailInfo & strAddedMailInfo

If Len(strMailInfo) Then
Call ShellExecute(Me.hWnd, "open", strMailInfo, vbNullString, _
vbNullString, SW_SHOWNORMAL)
End If

'Now that email has been sent clear all the text boxes
ClearText
End Sub

Private Sub ClearText()
txtToAddresses = ""
txtCCAddresses = ""
txtBCCAddresses = ""
txtSubject = ""
txtBody = ""
txtAttachmentLocation = ""
End Sub