Closed Thread
Results 1 to 3 of 3

Reg: Excel 2007 file autosending email using Microsoft Outlook 2007

Hybrid View

  1. #1
    Registered User
    Join Date
    09-25-2014
    Location
    Hyderabad India
    MS-Off Ver
    Office 2019
    Posts
    11

    Unhappy Reg: Excel 2007 file autosending email using Microsoft Outlook 2007

    Hi All,

    I am new to VBA and trying to learn the nitty-gritty of excel vba. My query is that I am trying to send an email automatically from my excel sheet through outlook 2007 application. It is a simple macro which checks for the condition for the first cell in row while using two other cell in the same row as email id and message bidy. The issue that I am facing is the loop which according to me is pretty simple but still it is giving the error "The object has been moved/deleted" while executing and sending the email successfully for the first cell in the range (Cells_M).

    Sub SendMail()
    
    Dim olApp As Outlook.Application
    Dim olMail As MailItem
    Dim Cell As Range
    Dim Cells_M As Range
    
    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)
    
    ActiveWorkbook.Save
    
    Set Cells_M = Range("A4:A6")
    
    For Each Cell In Cells_M
    
    If Cell.Value > Date Then
    
    With olMail
    .To = Cell.Offset(0, 4).Value 'I have tried Cell.Offset(0, 4).text also but same error". This cell has the email id
    .Subject = "Pending Reports"
    .Body = Cell.Offset(0, 1).Text 'This cell has text or the report which is pending
    .Send
    End With
    
    Else
    
    End If
    
    Next Cell
    
    Set olMail = Nothing
    Set olApp = Nothing
    
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Reg: Excel 2007 file autosending email using Microsoft Outlook 2007

    Can you attach a sample?
    Hope this helps

    Sometimes its best to start at the beginning and learn VBA & Excel.

    Please dont ask me to do your work for you, I learnt from Reading books, Recording, F1 and Google and like having all of this knowledge in my head for the next time i wish to do it, or wish to tweak it.
    Available for remote consultancy work PM me

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Reg: Excel 2007 file autosending email using Microsoft Outlook 2007

    Welcome to the Forum, pls take some minutes to read forum rules(as i suggestet in your other thread too) because in this case,unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    Thread Closed.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Reg: Excel file autosending email using Microsoft Outlook
    By abhimails in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2014, 10:47 AM
  2. export outlook 2007 email into excel with subject and body of email
    By akulka58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-25-2013, 02:37 PM
  3. Replies: 1
    Last Post: 11-01-2012, 10:00 AM
  4. microsoft excel 2007, macro to save attachments from outlook help
    By excelnoob1212 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2012, 09:18 AM
  5. Using Excel 2007 to Prepare an Email in Outlook 2007 in a customized format.
    By rahulin in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2010, 08:36 AM

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