![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Mar 2002
Location: India
Posts: 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 ================ |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
I have had the same problem so would be interested in any responses.
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
|
Not definitely sure if this will do the job but you may as well give it a go. If it works on machines where Outlook isn't the default mail application then you're onto a winner!
http://support.microsoft.com/default...;EN-US;q238114 You should be able to modify the code to suit your need. If not, then please repost. Regards, Dan |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: England
Posts: 212
|
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 |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Feb 2002
Location: Winnipeg, Manitoba, CANADA
Posts: 130
|
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
__________________
Thanx. |
|
|
|
|
|
#6 |
|
Board Regular
Join Date: Feb 2002
Location: Winnipeg, Manitoba, CANADA
Posts: 130
|
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
__________________
Thanx. |
|
|
|
|
|
#7 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
|
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Feb 2002
Location: Winnipeg, Manitoba, CANADA
Posts: 130
|
Nice Ivan!
How would I send an e-mail using a proxy e-mail address?
__________________
Thanx. |
|
|
|
|
|
#9 |
|
New Member
Join Date: Sep 2005
Posts: 1
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|