Sending email using default mail client ??

sam_d1

Board Regular
Joined
Mar 17, 2002
Messages
50
Hi all,
I use the following (Excel VB) code to send email.
But this requires 'OutLook'.
Is there a way to dynamically find (and use) any mail client ?

( It must be possible, because, if I type an e-mail id in a cell and click on that, Excel detects the default mail client of that machine and uses it to send the mail.)

thanks in advance
- sam


==================
Code segment start
==================
Private Sub Send_CommandButton_Click()
Dim OL As Object, MailSendItem As Object
Set OL = CreateObject("Outlook.Application")
Set MailSendItem = OL.CreateItem(olMailItem)
With MailSendItem
.Subject = "Subject"
.Body = "Message"
.To = "abc@xyz.com"
.cc = "abc@xyz.com"
.Send
End With
End Sub

================
Code segment End
================
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Dan

Managed to get it to work for Groupwise with a few amendments. However after the mail is sent Excel crashes, also not too sure how to attach a file. But, it is a start, thanks for the link.

Matt
 
Upvote 0
Try this... (got it from someone else, can't remember who??)

Sub GroupWiseSendMail(strLoginName, _
strMailPassword, _
strTo, _
strCC, _
strBCC, _
strSubject, _
strBody, _
strAttachFullPathName)

Dim sCommandOptions As String
Dim ogwNewMessage As GroupwareTypeLibrary.Mail

Const NGW$ = "NGW"

' Set application object reference if needed
If ogwApp Is Nothing Then ' Need to set object reference
DoEvents
Set ogwApp = CreateObject("NovellGroupWareSession")
DoEvents
End If

If ogwRootAcct Is Nothing Then ' Need to log in
' Login to root account
If Len(strMailPassword) Then ' Password was passed - use it
sCommandOptions = "/pwd=" & strMailPassword
Else ' Password was not passed
sCommandOptions = vbNullString
End If
Set ogwRootAcct = ogwApp.Login(strLoginName, sCommandOptions, _
, egwPromptIfNeeded)
DoEvents
End If

' Create new message
Set ogwNewMessage = ogwRootAcct.WorkFolder.Messages.Add _
("GW.MESSAGE.MAIL", egwDraft)
DoEvents


' Start adding recipients
With ogwNewMessage
With .Recipients
.Add strTo, NGW ', egwTo
'.Add strCC, NGW, egwCC ' Don't need this
'.Add strBCC, NGW, egwBCC ' Don't need this
End With

' Get the SUBJECT text
.Subject = strSubject

' Build the BODY text
.BodyText = strBody

' Create Attachment
.Attachments.Add strAttachFullPathName
'.Attachments.Add strFile2
' Send the Mail
On Error Resume Next
' Send method may fail if recipients don't resolve
.Send
DoEvents
On Error GoTo 0
End With

Set ogwNewMessage = Nothing
Set ogwRootAcct = Nothing
Set ogwApp = Nothing
DoEvents

End Sub
 
Upvote 0
oops, don't forget to make your reference to:
GroupWare Type Library

and your delcarations as folllows:
Private ogwApp As GroupwareTypeLibrary.Application
Private ogwRootAcct As GroupwareTypeLibrary.Account
 
Upvote 0
I've gotten great mileage out of the GroupwiseSendMail routine. Unfortunately, now that we've upgraded to 6.5.4, the routine has stopped working and I'm stymied. I don't get any error messages, so I haven't been able to figure out where the problem is.

Anyone else know anything about this?

Thx
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,397
Members
448,957
Latest member
Hat4Life

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top