+ Reply to Thread
Results 1 to 8 of 8

Sending Email

  1. #1
    Registered User
    Join Date
    12-21-2005
    Posts
    16

    Sending Email

    I want to be able to send an automated email through outlook express which attaches an excel spreadsheet.

    I have the following code which i used to use in outlook, but will not not work in my current set up.

    I've tried changing the Dim statment to look for outlook express rather than outlook but does not seem to like this either.

    Do I need an add in to allow me to do this, or can anyone suggest anything else

    Thanks
    K






    Sub Send()
    'Dim objOutlook As outlookexpress.Application
    Dim objmessage As outlook.MailItem
    Dim objAttach As outlook.Attachments

    'Creates objects to send mail
    Set objOutlook = CreateObject("Outlook.Application")
    Set objmessage = objOutlook.CreateItem(olMailItem)
    Set objAttach = objmessage.Attachments

    'Loads data into fields
    objmessage.To = "robert smith ; martin Gore"
    objmessage.Subject = "Stock Booked in By Day (DPS Report & Ret Report)"
    'This is the messgage in the body of email that recipients see
    objmessage.Body = "Dear All" & Chr(13) _
    & "Please find attached the files containing stock booked in and returned by day " & Chr(13) & Chr(13) & Chr(13) _
    & "Regards" & Chr(13) & Chr(13)


    'Attach's file to message depending if Sunday then attach full week file.
    'If Weekday(Now) = 1 Then
    objAttach.Add "\\hmvnetapp1\data\finsys\daily\DPS Report.xls"
    objAttach.Add "\\hmvnetapp1\data\finsys\daily\RET Report.xls"
    'Else
    'objAttach.Add "\\hmvnetapp1\strpublic\Finance\BaseBookingInReport.xls"
    'End If
    'Sets in expiriy time, just a housekeeping thing
    objmessage.ExpiryTime = Date + 2
    objmessage.Display
    End Sub
    Last edited by katmando; 03-02-2006 at 12:14 PM.

  2. #2
    Ron de Bruin
    Guest

    Re: Sending Email

    Hi katmando

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

    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "katmando" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I want to be able to send an automated email through outlook express
    > which attaches an excel spreadsheet.
    >
    > I have the following code which i used to use in outlook, but will not
    > not work in my current set up.
    >
    > I've tried changing the Dim statment to look for outlook express rather
    > than outlook but does not seem to like this either.
    >
    > Do I need an add in to allow me to do this, or can anyone suggest
    > anything else
    >
    > Thanks
    > K
    >
    >
    >
    >
    >
    >
    > Sub Send()
    > 'Dim objOutlook As outlookexpress.Application
    > Dim objmessage As outlook.MailItem
    > Dim objAttach As outlook.Attachments
    >
    > 'Creates objects to send mail
    > Set objOutlook = CreateObject("Outlook.Application")
    > Set objmessage = objOutlook.CreateItem(olMailItem)
    > Set objAttach = objmessage.Attachments
    >
    > 'Loads data into fields
    > objmessage.To = "robert smith ; martin Gore"
    > objmessage.Subject = "Stock Booked in By Day (DPS Report & Ret
    > Report)"
    > 'This is the messgage in the body of email that recipients see
    > objmessage.Body = "Dear All" & Chr(13) _
    > & "Please find attached the files containing stock booked in
    > and returned by day " & Chr(13) & Chr(13) & Chr(13) _
    > & "Regards" & Chr(13) & Chr(13)
    >
    >
    > 'Attach's file to message depending if Sunday then attach full week
    > file.
    > 'If Weekday(Now) = 1 Then
    > objAttach.Add "\\hmvnetapp1\data\finsys\daily\DPS Report.xls"
    > objAttach.Add "\\hmvnetapp1\data\finsys\daily\RET Report.xls"
    > 'Else
    > 'objAttach.Add
    > "\\hmvnetapp1\strpublic\Finance\BaseBookingInReport.xls"
    > 'End If
    > 'Sets in expiriy time, just a housekeeping thing
    > objmessage.ExpiryTime = Date + 2
    > objmessage.Display
    > End Sub
    >
    >
    > --
    > katmando
    > ------------------------------------------------------------------------
    > katmando's Profile: http://www.excelforum.com/member.php...o&userid=29803
    > View this thread: http://www.excelforum.com/showthread...hreadid=518286
    >




  3. #3
    Registered User
    Join Date
    12-21-2005
    Posts
    16
    Thanks for that. I had found the site before but couldn't quite get the code to do what wanted.
    I'll play around with it a bit more


    Cheers
    K

  4. #4
    Les Stout
    Guest

    Re: Sending Email

    Hi K,

    I use the following very succesfully.

    Sub email()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim EmailAddr As String
    Dim Subj As String
    Dim BodyText As String

    EmailAddr = "[email protected]"
    Subj = "Your subject"

    BodyText = "your subject"

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    With OutMail
    .to = EmailAddr
    .CC = ""
    .BCC = ""
    .Subject = Subj
    .Body = BodyText
    .Attachments.Add ActiveWorkbook.FullName
    .Display 'or use .send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing
    End sub



    Les Stout

    *** Sent via Developersdex http://www.developersdex.com ***

  5. #5
    Registered User
    Join Date
    12-21-2005
    Posts
    16
    Hi Les
    Thats great, my only problem is that i'm using outlook express, and this code opens outlook. I can't seem to find the application name for outlook Express, to replace

    Set OutApp = CreateObject("Outlook.Application")

    Cheers
    K

  6. #6
    Ron de Bruin
    Guest

    Re: Sending Email

    With OE it is not possible to send files and text in the body.
    The only option you have is CDO
    http://www.rondebruin.nl/cdo.htm


    --
    Regards Ron de Bruin
    http://www.rondebruin.nl


    "katmando" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi Les
    > Thats great, my only problem is that i'm using outlook express, and
    > this code opens outlook. I can't seem to find the application name for
    > outlook Express, to replace
    >
    > Set OutApp = CreateObject("Outlook.Application")
    >
    > Cheers
    > K
    >
    >
    > --
    > katmando
    > ------------------------------------------------------------------------
    > katmando's Profile: http://www.excelforum.com/member.php...o&userid=29803
    > View this thread: http://www.excelforum.com/showthread...hreadid=518286
    >




  7. #7
    Registered User
    Join Date
    12-21-2005
    Posts
    16
    Thanks Ron
    I had a look at your site again before and figured as much..... Managed to get a work around by using an example on your site.

    Great site you've got there, very helpful

    Cheers
    K

  8. #8
    Registered User
    Join Date
    12-21-2005
    Posts
    16
    Ron
    Just tried the code you linked to, Excellent, A lot better than my work around.

    Thanks again

    K

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1