2017-07-31 14 views
0

添付ファイルの少ないメールを別のクライアントに送信する必要があります。添付ファイルは、それぞれが名前で命名された異なるフォルダに置かれます。例えば電子メールで送信するファイルを添付するEXCEL

..

In column "A" = Clients name 
In column "B" = Clientes emails 
In column "C" = The subject 
In column "D" = The email body (ex: Hello, here the attachemtn) 
In column "E" = The folder where the attachemtns are on 

私は、各clienteのための1つのルーチンを持っている必要があります(+ - 14 clientes)。 これについて何か成功したことを指摘しています。 ヘルプがありますか?

サブのsendEmail()

Dim MyOlapp As Object, MeuItem As Object 
Set MyOlapp = CreateObject("Outlook.Application") 
Set MeuItem = MyOlapp.CreateItem(olMailItem) 
With MeuItem 
.to = Range("A2") 
.Subject = Range("D2") 
.Body = "Range("C2") 

End With 
End Sub 

答えて

1

ここで私は自分の環境に合わせて編集し、...添付ファイル付きもちろん

Sub NLANghtRpt() 
Dim myItem As Outlook.MailItem 
Dim myAttachments As Outlook.Attachments 

'location of your files 
myPath1 = "C:\Users\username\Documents\" 


Set myItem = Application.CreateItem(olMailItem) 
With myItem 
    .To = "whoever you want to send to" 
    .CC = "whoever you want to copy" 
    .Subject = "your subject here" 
    .Body = "NIGHTLY REPORT FOR " & Format(Now, "mm.dd.yy") 
     ' I use the previous line for a generic message with a time stamp 

Set myAttachments = myItem.Attachments 

myAttachments.Add myPath1 & ("ReportSchedule.xls") 
myAttachments.Add myPath1 & ("ReportBooks.xls") 
myAttachments.Add myPath1 & ("ReportHours.xls") 


myItem.Display 
End With 
End Sub 

メールを送信するにはOutlook用に使用するスクリプトです。幸運

関連する問題