I've got this code in my access database behind a button. What I want to be able to do is to have it look for the value in the dropdown and based on the value attach a .pdf file to the email upon execution. Can you help me out with this. I've got it pretty much on its way, it just needs a little tweeking...
Private Sub Command4_Click()
On Error GoTo Err_Command5_Click
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim MyBodyText As String
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim strSql As String
Dim myattachments As Variant
Dim lItemCount As Long
Dim mailStationery As String
'send email with spreadsheet
Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = "jwsullivan@gaic.com"
MyMail.CC = ""
MyMail.BCC = Text1
MyMail.BodyFormat = olFormatHTML
MyMail.Subject = "Monthly Newsletter"
MyBodyText = "Here is the document"
Set myattachments = MyMail.Attachments
myattachments.Add "C:\JetComp.doc"
MyMail.SentOnBehalfOfName = "Great American SHS NonProfit"
'******************************************************
'put the HTML code for the stationery to a variable and then assign
'it to the HTMLBody
If Combo16.Value = "Newsletter" Then
mailStationery = ""
mailStationery = mailStationery & ""
mailStationery = mailStationery & ""
mailStationery = mailStationery & ""
mailStationery = mailStationery & "
"
mailStationery = mailStationery & "
"
mailStationery = mailStationery & "
"
Else
mailStationery = ""
End If
'******************************************************
MyMail.HTMLBody = mailStationery
'MyMail.HTMLBody = "My HTML Background" & _
""
MyMail.Display
Set MyMail = Nothing
Set myattachments = Nothing
Set MyOutlook = Nothing
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub
Private Sub Command4_Click()
On Error GoTo Err_Command5_Click
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim MyBodyText As String
Dim frm As Form
Dim ctl As Control
Dim varItem As Variant
Dim strSql As String
Dim myattachments As Variant
Dim lItemCount As Long
Dim mailStationery As String
'send email with spreadsheet
Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = "jwsullivan@gaic.com"
MyMail.CC = ""
MyMail.BCC = Text1
MyMail.BodyFormat = olFormatHTML
MyMail.Subject = "Monthly Newsletter"
MyBodyText = "Here is the document"
Set myattachments = MyMail.Attachments
myattachments.Add "C:\JetComp.doc"
MyMail.SentOnBehalfOfName = "Great American SHS NonProfit"
'******************************************************
'put the HTML code for the stationery to a variable and then assign
'it to the HTMLBody
If Combo16.Value = "Newsletter" Then
mailStationery = ""
mailStationery = mailStationery & ""
mailStationery = mailStationery & ""
mailStationery = mailStationery & ""
mailStationery = mailStationery & "
"
mailStationery = mailStationery & "
"
mailStationery = mailStationery & "
"
Else
mailStationery = ""
End If
'******************************************************
MyMail.HTMLBody = mailStationery
'MyMail.HTMLBody = "My HTML Background" & _
""
MyMail.Display
Set MyMail = Nothing
Set myattachments = Nothing
Set MyOutlook = Nothing
Exit_Command5_Click:
Exit Sub
Err_Command5_Click:
MsgBox Err.Description
Resume Exit_Command5_Click
End Sub