Michael M
Well-known Member
- Joined
- Oct 27, 2005
- Messages
- 21,896
- Office Version
- 365
- 2019
- 2013
- 2007
- Platform
- Windows
Hi All
I have the following code which I modified from Ron DeBruins site...thanks again Ron.
However, I am trying to let the user add more attachments if required. There is already one "standard" attachment, which is done automatically
At the moment, I have an IF / Then statement , which switches from .display to .send, but the user has to go and select the files each time.
I am curious to know if there is a snippet of code that will alllow the user to open the Insert dialog box or Explorer, select the files to insert and then "plant' the selected files into the code as a variable.
This is a mailout for price tendering and whan extra attachments are required it could apply to a dozen or so E-Mails. Given that I am sending out hundreds, it's no big deal, but it would help speed things up.
Any assistance or even alternative methods would be appreciated
I have the following code which I modified from Ron DeBruins site...thanks again Ron.
However, I am trying to let the user add more attachments if required. There is already one "standard" attachment, which is done automatically
At the moment, I have an IF / Then statement , which switches from .display to .send, but the user has to go and select the files each time.
I am curious to know if there is a snippet of code that will alllow the user to open the Insert dialog box or Explorer, select the files to insert and then "plant' the selected files into the code as a variable.
This is a mailout for price tendering and whan extra attachments are required it could apply to a dozen or so E-Mails. Given that I am sending out hundreds, it's no big deal, but it would help speed things up.
Any assistance or even alternative methods would be appreciated
Code:
Set OutMail = OutApp.CreateItem(0)
With Dest
.SaveAs TempFilePath & TempFileName & FileExtStr, _
FileFormat:=FileFormatNum
On Error Resume Next
lr = Sheets("List").Cells(Rows.Count, "A").End(xlUp).Row
Email_Send_From = ""
ans = MsgBox("Will you need to add further attachments ??", vbYesNo)
For i = lr To 8 Step -1
If Sheets("List").Range("G" & i).Value = 1 Then
Set Mail_Object = CreateObject("Outlook.Application")
With Mail_Object.CreateItem(o)
.Subject = Sheets("User").Range("B4")
.To = Sheets("List").Range("D" & i).Value
.Body = Sheets("User").Range("B6") & Chr(13) & Chr(13) & Sheets("User").Range("B8")
.Attachments.Add Dest.FullName
If ans = vbYes Then
.display 'requires to send the Email manually
End If
'.send ' will automatically send the email
End With
End If
Next
On Error GoTo 0
.Close SaveChanges:=False
End With