+ Reply to Thread
Results 1 to 2 of 2

Attachment is added Twice while sending emial through Excel

  1. #1
    Registered User
    Join Date
    02-26-2011
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    8

    Attachment is added Twice while sending emial through Excel

    I have added below code and when I click the button second time, attachment is added twice. Kindly let me know the problem in my VBA code:
    <Code>





    Private Sub Email_Click()
    Dim Fname As String
    Dim EmailAddress As String
    Fname = Environ$("temp") & "\Testing_Status.gif"
    EmailAddress = InputBox("Enter Complete Email Address to whom you want to send Testing Status.")
    If EmailAddress = "" Then
    Kill Fname
    Exit Sub
    End If

    'Fname = Environ$("temp") & "\Testing_Status.gif"
    ActiveWorkbook.Worksheets("Testing Status").ChartObjects("Chart 1").Chart.Export _
    Filename:=Fname, FilterName:="GIF"


    ActiveSheet.UsedRange.Select
    ActiveWorkbook.EnvelopeVisible = True

    With ActiveSheet.MailEnvelope
    .Introduction = "Test Status Matrix is as shown below and graphical bar chart is attached."
    .Item.To = EmailAddress
    .Item.Subject = "Testing Status"
    .Item.Attachments.Add Fname
    .Item.Send
    End With
    Kill Fname
    End Sub
    </Code>

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Attachment is added Twice while sending emial through Excel

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

+ 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