-
Jul 15th, 2021, 12:08 PM
#1
Thread Starter
Lively Member
[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
-
Jul 15th, 2021, 12:22 PM
#2
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!
-
Jul 15th, 2021, 12:23 PM
#3
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
-
Jul 15th, 2021, 12:58 PM
#4
Re: Send Email
Originally Posted by couttsj
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!
-
Jul 15th, 2021, 01:20 PM
#5
Thread Starter
Lively Member
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.
-
Jul 15th, 2021, 02:07 PM
#6
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?
-
Jul 15th, 2021, 03:28 PM
#7
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.
-
Jul 15th, 2021, 11:34 PM
#8
Junior Member
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.
-
Jul 16th, 2021, 04:18 AM
#9
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
-
Jul 16th, 2021, 06:53 AM
#10
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.
-
Jul 16th, 2021, 07:14 AM
#11
Re: Send Email
Originally Posted by DataMiser
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!
-
Jul 16th, 2021, 01:17 PM
#12
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|