Hi Guys
Hoping to rack your brains. I've sorted the multiple attachment problem.
It's base on a qry such as:
E-mailAddress_________Attachment1_________Attachment2
?????????????_________C:\XXXXXXX_________C:\XXXXXXXX
My issue is I have a list of pdf's which I can easily convert to a link:
DeviationScreenshotID________ Attachment
1 ________________________C:\XXXXXX\1.pdf
2 ________________________C:\XXXXXX\2.pdf
3 ________________________C:\XXXXXX\3.pdf
I want to be able to move through the list of attachments adding to an email.
I could do this by sending multiple e-mails but that's harsh on the recievers. I'm not sure just how to go about this.
Any ideas on potential solutions would be welcome.
Thanks
Hoping to rack your brains. I've sorted the multiple attachment problem.
It's base on a qry such as:
E-mailAddress_________Attachment1_________Attachment2
?????????????_________C:\XXXXXXX_________C:\XXXXXXXX
My issue is I have a list of pdf's which I can easily convert to a link:
DeviationScreenshotID________ Attachment
1 ________________________C:\XXXXXX\1.pdf
2 ________________________C:\XXXXXX\2.pdf
3 ________________________C:\XXXXXX\3.pdf
I want to be able to move through the list of attachments adding to an email.
I could do this by sending multiple e-mails but that's harsh on the recievers. I'm not sure just how to go about this.
Code:
Private Sub EMailButton1_Click()
Dim mydatabase As Database
Dim rst As Recordset
Set mydatabase = CurrentDb
Set rst = mydatabase.OpenRecordset("qryEmailWastage", dbOpenDynaset) 'qryemail is the query that gets the data to be sent excluding attachments
Dim DisplayMsg As Boolean
Dim strTo As String
Dim strCC As String
Dim strBCC As String
Dim strSubject As String
Dim strBody As String
Dim strAttachPathFile As String
Dim strAttachPathFile1 As String
i = 0
Const NGW$ = "NGW"
Dim GWCom As Object
Dim RetStr As String, MessageId As String
Dim gwappl As Object, gwacc As Object, gwnewmessage As Object
Set gwappl = CreateObject("NovellGroupWareSession")
Set gwacc = gwappl.Login
Do While rst.AbsolutePosition <> -1
strTo = rst!EmailAddress
strCC = XXXXXX
'use rst!email_plaintext for the recipient
'subject and body contents
strSubject = rst!ReportTitle
strBody = "Dear " & rst!ReportSendTo & "," & vbCrLf & vbCrLf & _
"Please see the attached Wastage Reports for " & rst!Period & vbCrLf & vbCrLf & _
"Kind Regards" & vbCrLf & _
"Thicko"
Set gwnewmessage = gwacc.WorkFolder.Messages.Add("GW.Message.mail")
' Create the message
With gwnewmessage
With .Recipients
' Add the To recipient(s) to the message
If (strTo <> "") Then
.Add strTo, NGW
End If
' Add the CC recipient(s) to the message
If (strCC <> "") Then
.Add strCC, NGW
End If
' Add the BCC recipient(s) to the message
If (strBCC <> "") Then
.Add strBCC, NGW
End If
End With
' Set the Subject, Body, and Importance of the message
.Subject = strSubject
.BodyText = strBody
.Priority = 2
' Add attachments to the message.
strAttachPathFile = ""
strAttachPathFile1 = ""
If (rst!ReportLocation <> "") Then
strAttachPathFile = rst!ReportLocation
strAttachPathFile1 = rst!ReportLocation1
End If
If (strAttachPathFile <> "") Then
'MsgBox strAttachPathFile
.Attachments.Add strAttachPathFile
.Attachments.Add (strAttachPathFile1)
End If
' Should we display the message before sending?
If DisplayMsg Then
' Display message to user
MessageId = .MessageId
Set GWCom = CreateObject("GroupwiseCommander")
GWCom.Execute "ItemOpen (""" & MessageId & """)", RetStr
Else
.Send
End If
End With
Set gwnewmessage = Nothing
i = i + 1
rst.MoveNext
Loop
Me!OLEUnbound25.SetFocus
Me.EmailBox1.Visible = False
Me.EMailButton1.Visible = False
MsgBox i & " messages have been sent"
End Sub
Any ideas on potential solutions would be welcome.
Thanks