Dear friends 

 

Below you can find the code I wrote to make Excel send emails thought a list
of names

 

My problem is the attachment talk. 

 

I need a code that gets all files from a certain directory and attach into
the email using the " .attachment.Add"

 

Does anyone know how to do that ? 

 

Thanks in advance 

 

Dim olApp As Object

Dim olMail As Object

Dim olSubject

Dim olTratamneto

Dim olName

Dim olMsg

Dim FirstLine

Dim LastLine

Dim olAttachment As FileDialog

Dim olAttachmentDirectory As Object

 

LastLine = Cells(65536, 1).End(xlUp).Row

 

olTratamento = InputBox("Insira aqui uma mensagem que vem antes do Nome do
seu cliente como Dear,Hello, Etc" _

, "Tratamento da Mensagem", "Hello ")

 

olSubject = InputBox("Insira o assunto do email", "Subjetc Box", "BROTHERS
IN GRANITE OFFER")

 

Set olApp = CreateObject("Outlook.application")

Set olMail = olApp.CreateItem(0)

Set olAttachment = Application.FileDialog(msoFileDialogFilePicker)

With olAttachment

.AllowMultiSelect = True

End With

 

FirstLine = 2

For i = FirstLine To LastLine

    olName = Cells(FirstLine, 1).Value

    With olMail

        .OriginatorDeliveryReportRequested = True ' delivery confirmation

        .ReadReceiptRequested = True ' read confirmation

        .Subject = olSubject

        .To = Cells(FirstLine, 2).Value

        .CC = Cells(FirstLine, 3).Value

        .BCC = Cells(FirstLine, 4).Value

        .Body = olTratamneto & Chr(32) & Cells(FirstLine, 1).Value & Chr(13)
& Chr(13) & Sheets("MAIL_OFFER").Cells(1, 1).Value

        .Attachment.Add = "Several file"

    End With

Next i

End Sub

 

 

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 6,800 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to