View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
MD MD is offline
external usenet poster
 
Posts: 1
Default attached file using outlook

Hi,
i am using the following cource to attach a file to a outlook mail (thanks
to Ron de Bruin):

Sub TestFile()
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim cell As Range Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application") On Error GoTo
cleanup
For Each cell In
Sheets("Sheet1").Columns("B").Cells.SpecialCells(x lCellTypeConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Value Like "*@*" And Dir(cell.Offset(0, 1).Value) < ""
Then
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = cell.Value
.Subject = "Testfile"
.Body = "Hi " & cell.Offset(0, -1).Value
.Attachments.Add cell.Offset(0, 1).Value
.Display 'Or use Display
End With
Set OutMail = Nothing
End If
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End SubThe problem is, whenever i am trying to add a html file, Outlook
pastes its content into the mail (i guess it comes from my outlook settings
to send mail in html-format). How can i prevent from this? I do need to send
it as attachement.Thanks in advance.