Thanks Thanks:  0
Likes Likes:  0
Results 1 to 9 of 9

Thread: Sending email using default mail client ??

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    India
    Posts
    50
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I have had the same problem so would be interested in any responses.

  3. #3
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    2,940
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #4
    Board Regular
    Join Date
    Feb 2002
    Location
    England
    Posts
    212
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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. #5
    Board Regular
    Join Date
    Feb 2002
    Location
    Winnipeg, Manitoba, CANADA
    Posts
    144
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sending email using default mail client ??

    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. #6
    Board Regular
    Join Date
    Feb 2002
    Location
    Winnipeg, Manitoba, CANADA
    Posts
    144
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sending email using default mail client ??

    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. #7
    MrExcel MVP Ivan F Moala's Avatar
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    4,209
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Have a look here to use your default mailer.......

    http://www.xcelfiles.com/Outlook_01.html
    Kind Regards,
    Ivan F Moala From the City of Sails

  8. #8
    Board Regular
    Join Date
    Feb 2002
    Location
    Winnipeg, Manitoba, CANADA
    Posts
    144
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Sending email using default mail client ??

    Nice Ivan!

    How would I send an e-mail using a proxy e-mail address?
    Thanx.

  9. #9
    New Member
    Join Date
    Sep 2005
    Posts
    1
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •