Есть excel-й файл, в котором содержаться данные о пользователи(ФИО, тел). Надо эти данные добавлять в подпись сообщения в outlook
Код |
---|
Sub Подпись() ' Dim OutApp As Object, OutMail As Object, Strbody As String, r As Date, SigString As String, Signature As String Set OutApp = CreateObject("Outlook.Application" ;) OutApp.Session.Logon: Set OutMail = OutApp.CreateItem(0) On Error Resume Next r = Format(Now(), "dd mmmm yyyy" ;) Strbody = "Добрый день!" [B] Вот здесь должны быть данные из excel[/B] If Dir(SigString) <> "" Then Signature = GetBoiler(SigString) Else Signature = "" End If With OutMail .To = "": .CC = "": .BCC = "": .Subject = "": .Body = Strbody & vbNewLine & vbNewLine & Signature .Attachments.Add ("C:\test.xls" ;) .Display 'or use .send End With On Error GoTo 0: Set OutMail = Nothing: Set OutApp = Nothing End Sub Function GetBoiler(ByVal sFile As String) As String ' Dim fso As Object Dim ts As Object Set fso = CreateObject("Scripting.FileSystemO bject" ;) Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2) GetBoiler = ts.readall ts.Close End Function |