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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Oulook Mail Merge Attachment 1

Status
Not open for further replies.

q

Technical User
Mar 22, 2000
2
US
Hi,<br>
<br>
Does anyone know how to mail merge to an email AND have a separate document attachment? You can attach the word merge document to an email but I have the content of the email be my Word document and I want to attach a different document to the email. Is there a field code or some programming that will allow me to do this?<br>
<br>
Thanks,<br>
q
 
This will work if you have something that uses VBA like Access or maybe Outlook 2000<br>
------------------------<br>
Put this in your Module<br>
------------------------------<br>
Public Declare Function ShellExecute Lib &quot;shell32.dll&quot; Alias &quot;ShellExecuteA&quot; (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<br>
------------------------------<br>
put this in a command button<br>
------------------------------<br>
Private Sub Command0_Click()<br>
On Error GoTo Err_Command0_Click<br>
<br>
Dim stext As String<br>
Dim sAddedtext As String<br>
If Len(txtMainAddresses) Then<br>
stext = txtMainAddresses<br>
End If<br>
If Len(txtCC) Then<br>
sAddedtext = sAddedtext & &quot;&CC=&quot; & txtCC<br>
End If<br>
If Len(txtBCC) Then<br>
sAddedtext = sAddedtext & &quot;&BCC=&quot; & txtBCC<br>
End If<br>
If Len(txtSubject) Then<br>
sAddedtext = sAddedtext & &quot;&Subject=&quot; & txtSubject<br>
End If<br>
If Len(txtBody) Then<br>
sAddedtext = sAddedtext & &quot;&Body=&quot; & txtBody<br>
End If<br>
If Len(txtAttachment) Then<br>
sAddedtext = sAddedtext & &quot;Attach=&quot; & Chr$(34) & Me!txtAttachment & Chr$(34)<br>
End If<br>
<br>
stext = &quot;mailto:&quot; & stext<br>
<br>
If Len(sAddedtext) &lt;&gt; 0 Then<br>
Mid$(sAddedtext, 1, 1) = &quot;?&quot;<br>
End If<br>
<br>
stext = stext & sAddedtext<br>
<br>
' launch default e-mail program<br>
If Len(stext) Then<br>
Call ShellExecute(Me.hwnd, &quot;open&quot;, stext, vbNullString, vbNullString, SW_SHOWNORMAL)<br>
End If<br>
<br>
Exit_Command0_Click:<br>
Exit Sub<br>
<br>
Err_Command0_Click:<br>
MsgBox Err.Description<br>
Resume Exit_Command0_Click<br>
<br>
End Sub<br>
<br>
------------------------------ <p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top