Results 1 to 12 of 12

Thread: [RESOLVED] Send Email

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    Resolved [RESOLVED] Send Email

    Sorry but I have a new thread for a similar problem. Can anyone see why this code will not send email. Outlook mail pops up and the attachment is there but when I send it, it doesn't show up in mailbox.

    Dim myItem As Outlook.MailItem
    Dim myAttachments As Outlook.Attachments
    Set myItem = Application.CreateItem(olMailItem)
    Set myAttachments = myItem.Attachments
    myAttachments.Add "C:\my file", _
    olByValue, 1, "Electricity Usage"
    myItem.Display

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,836

    Re: Send Email

    If I understand the email pops up and you send it. I don't think it is a VB issue then. Look at it like you are sending any other email.
    Please remember next time...elections matter!

  3. #3
    Frenzied Member
    Join Date
    Dec 2012
    Posts
    1,477

    Re: Send Email

    It depends on the nature of the attachment and the ESP you are using. For example, if you are using Gmail and sending a ".pdf" file, Gmail will simply block it without advising you.

    J.A. Coutts

  4. #4
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,836

    Re: Send Email

    Quote Originally Posted by couttsj View Post
    It depends on the nature of the attachment and the ESP you are using. For example, if you are using Gmail and sending a ".pdf" file, Gmail will simply block it without advising you.

    J.A. Coutts
    He mentioned it was Outlook but I agree...it is no longer a VB issue at that point. You would think there would be a message somewhere it rejected. But I agree and try sending it without the attachment.
    Please remember next time...elections matter!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    Re: Send Email

    Still won't send (show up in inbox) without attachment. One thing that I've learned in VB 6 is you fix one thing and 10 other things go wrong and need fixing. LOL! But I love learning and you guys are the best with helping! Is there any suggestions to other email sending suggestions? I'm certainly not married to this one.
    Last edited by RLPeloquin; Jul 15th, 2021 at 01:26 PM.

  6. #6
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,138

    Re: Send Email

    Maybe take a step or two back. Is Outlook mail actually configured properly to send and/or receive email? If you take your VB 6 code completely out of the picture, and just attempt to send an email via Outlook mail completely manually, does that email show up in your Inbox?

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Send Email

    Am I missing something? There does not appear to be any code there that looks like it actually does a send. IT appears to create a mail item and an attachment and apparently attempts to display it but I see nothing for the destination address nor to trigger a send.

    I suppose maybe the user is addressing it and hitting send in outlook but if that is the case then it as stated above is not a VB issue.

  8. #8
    Junior Member
    Join Date
    Jun 2017
    Posts
    26

    Re: Send Email

    Under References do you have CDO For Windows 2000 library attached?

    Outlook Mail should not pop up as normal behavior when using the proper library.

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Send Email

    even if there was code to send an email (myitem.send) and recipient, optionally subject and body etc, which is not included in the original post, outlook will probably block attempts to send emails using outside automation
    very similar code will work from within outlook vba, but from vb6 outlook may present a dialog to confirm sending the email, which may not be visible to the user
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Send Email

    There is no VB question here at all. Puppeteering Outlook is the same in any language, it's an Outlook issue and belongs in the Office forum.

    You could use CDO for Windows if your goal is just spamming, but you'll probably have to get a paid account with a spam-friendly SMTP mail relay service.

  11. #11
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,836

    Re: Send Email

    Quote Originally Posted by DataMiser View Post
    Am I missing something? There does not appear to be any code there that looks like it actually does a send. IT appears to create a mail item and an attachment and apparently attempts to display it but I see nothing for the destination address nor to trigger a send.

    I suppose maybe the user is addressing it and hitting send in outlook but if that is the case then it as stated above is not a VB issue.
    It looks like it was coded to just display. We have that in place in a couple of applications per user request. They want to review the mail merge attachment before it goes out.
    Please remember next time...elections matter!

  12. #12

    Thread Starter
    Lively Member
    Join Date
    May 2021
    Posts
    87

    Re: Send Email

    Seems like Outlook needs to be open when sending to other emails like yahoo, gmail, etc.... No problem I can live with that. Works great!

Posting Permissions

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



Click Here to Expand Forum to Full Width