ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Send mail using default client (https://www.excelbanter.com/excel-programming/394865-send-mail-using-default-client.html)

Sudeep

Send mail using default client
 
I want to send an email with attachments using the default email client
through VBA.
My current program sends the mail using Microsoft outlook.

Is there any way through which I can send an email with an attachment using
the default email client which can be lotus notes, Netscape email client etc.

My current code goes like this:

Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim samp As String
With Application
..EnableEvents = False
..ScreenUpdating = False
End With
Set sh = Sheets(1)
Set OutApp = CreateObject("outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
..To = "
..Subject = €œSubject line€
..Attachments.Add €œC:/text.txt€
..Body = "Text in body"
..Display

Tom Ogilvy

Send mail using default client
 
If you just want to send the attachment, then use the Sendmail command. If
you want to write a message in the body, then you might have to use CDO. See
Ron de Bruin's site:

http://www.rondebruin.nl/sendmail.htm

--
Regards,
Tom Ogilvy


"Sudeep" wrote:

I want to send an email with attachments using the default email client
through VBA.
My current program sends the mail using Microsoft outlook.

Is there any way through which I can send an email with an attachment using
the default email client which can be lotus notes, Netscape email client etc.

My current code goes like this:

Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim samp As String
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set sh = Sheets(1)
Set OutApp = CreateObject("outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = "
.Subject = €œSubject line€
.Attachments.Add €œC:/text.txt€
.Body = "Text in body"
.Display



All times are GMT +1. The time now is 10:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com