×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Sending emails from VFP9 with CDO - Where’s the sent email
2

Sending emails from VFP9 with CDO - Where’s the sent email

Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Hi all

There are lots of examples on this forum for the above subject and I have managed to successfully implement one which sends an email seamlessly from VFP9. Perfect!

However, unlike automating an Outlook email which stores a copy in a sent folder, where (if at all) is the sent folder/place for the sent email using CDO?

Part of my app I’m putting together adds a Y to a field after the auto email process has run but if I need to refer back to the actual email sent, how would I do that or if not, any suggestions would be helpful.

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

Steve,

The short answer is that the sent message not saved anywhere.

Unlike Outlook, a VFP program that sends mail is not a full email client. It does not have inboxes or outboxes or any folders such as for drafts or sent messages. All that the program does is to send a message.

Essentially, it is up to you to implement your own Sent folder. How you do that depends on your needs. You could, for example, copy the email's text, and its To, From, Subject, etc, to a text file, which you would store somewhere in your file system. Or to a record in a DBF. You could then write code that lets you browse, search, etc. the sent messages, and bring selected messages to the screen.

Another option would be to send a blind copy of the message to your own email address, and then to access it through Outlook or another email client. Or, going further, you could use Outlook Automation for the whole job, rather than CDO. You could automate Outlook to send the message, in which case the message would automatically be saved in the Sent folder, which you could then access from within your program. This would also let you use Outlook's other feature, such as templates, signatures, etc. But that approach would mean you rewriting all the relevant code. And also require the users to have Outlook installed.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Sending emails from VFP9 with CDO - Where’s the sent email

Actually, it depends.

That doesn't contradict Mike Lewis, but it depends what exactly you do, which version of CDO you use and what else is installed.
In context of Exchange or an own SMTP Server the mails end up in a Pickup directory. That's also at the same time the reason Mike is right. If your CDO configuration sets up the usage of an external SMTP Server, that pickup folder also exists, if at all, there and not locally.

Using CDO with an Exchange server would usually only play a role in a company that runs it as many mails are internal and then you can keep mails from employee to employee internal and confidential.

I don't know, but if you do all this for yourself, you will likely neither run your own SMTP mail server or even more specifically an Exchange server, so Mike is usually right.

If you don't work in an environment with an Exchange server you might also not want to install one, surely not with any end user, ie in a private household. Setting up your own SMTP server is not that absurd, if you do web development and already run a web server and maybe even an ftp server. An smtp server would just complete this.

Without all this background, an outbox or sent mail box or folder is not part of the mail protocol, that's only concerned with how to connect to a mail server, authenticate as valid user and send the mail(s) over. Storing the sent mail is no must for code sending mails. Notice MAPI (which defines folder objects) is not short for Mail APplication Interface, but Messaging APplication Interface. Mail standards are MIME, SMTP, IMAP and perhaps some more.

Chriss

RE: Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Mike

The suggestion of a bcc sounds like the best and perhaps, the easiest option in my circumstances. I would then have a copy sent to my Outlook inbox. That makes sense.

Chris

Thank you for your post. I don’t run a server etc, so to keep it simple, I’ll implement a bcc of the email sent.

Appreciate the experts posts!

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

If this is about a newsletter, actually I would inverse your strategy. Make your own mail address the only TO addressee and put all newsletter receivers into BCC, so you don't send mail addresses of subscribers to other subscribers and only reveal your origin mail address, which you reveal anyway. It's good practice to use a noreply@somehere.com type of address and indicate this is an account not observed, even if sending a response to noreply does arrive.

Chriss

RE: Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Hi Chris

This is not about newsletters etc, it’s about me sending invoices but having had much success using Outlook with VFP, the environment where my app is being used now, has Office 365 therefore, hence my reason for an alternative.

Mike Lewis posted on another thread about an API for use with 365 but that is beyond my experience.
I’m happy now, matter resolved.

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

Download the Desktop versions and you can automate Outlook again.

Chriss

RE: Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Chris

Quote:

Download the Desktop versions and you can automate Outlook again.

So I have called into my friends office today and he is using a desktop version of Office 365.

I currently use the below to create and send emails via Outlook:

CODE -->

oOutlook = Createobject('Outlook.Application')
oNameSpace = oOutlook.getnamespace('MAPI')
oOutbox = oNameSpace.GetDefaultFolder(4)
oItems = oOutbox.Items
oMailItem = oItems.Add(0)
oMailItem.To = "anemailaddress.com"
oMailItem.Subject = "The subject line"
oMailItem.HtmlBody = HtmlBody
oMailItem.attachments.add("\pdfs\"+mypdf+'.pdf')
oMailItem.ReadReceiptRequested = .T.
*oMailItem.Display
oMailItem.Send 

I'll do some research now on Office 365 and post back. Is it worth me starting a new thread?

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Mike

You mentioned in this thread thread184-1808854: Automating Outlook 365 from VFP:

Quote (Mike Lewis)

I've now had an opportunity to test my original code using 365, and I'm pleased to report that it ran flawlessly, without any changes - as predicted by Nigel, above. (And the SMTP authentication issue doesn't seem to be a problem.)

Are you saying that you didn't have to change any coding similar to what I have posted or is there something else please?

I don't have Office 365 desktop so it's difficult to test.

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

Quote:

Are you saying that you didn't have to change any coding similar to what I have posted

That's right. My code is a bit different from yours. But the point is that the code that worked with pre-365 Outlook works exactly the same with the desktop version of 365. At least, that was my experience. So I think it's safe to assume that you won't need to change anything in your code.

And with this code, a copy of the outgoing message should end up in the Sent folder.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Thank you Mike, very much appreciated.

I'll have to see if I can find a trial version of Office 365 just to satisfy my curiosity and confirmation.

Best wishes

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

(OP)
Just an update on this for anyone who may be interested or searching this forum:

I signed up for an Office 365 free month trial just to establish if the coding I posted and to confirm Mike's comments that not much was changed to allow VFP to send emails with existing codeand Chris' mention "Download the Desktop versions and you can automate Outlook again"

I am pleased to say that it worked perfctly.

Comments and posts are much appreciated.

Thank you

Steve Williams
VFP9, SP2, Windows 10

RE: Sending emails from VFP9 with CDO - Where’s the sent email

Delighted to see that it is all working, Steve. Thanks for letting us know.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Sending emails from VFP9 with CDO - Where’s the sent email

Here a way to doo this with CDO

Local lcFileName,lcStr
Local lcPathtosave,omsg
lcPathtosave = 'c:\emails\sent\'
lcFileName = Sys(2015)+'.eml'
lcFileName=lcPathtosave+lcFileName
omsg = Createobject("CDO.Message")
omsg.To ='mike@somewhere.com'
omsg.From ='me'
omsg.subject ='test1'
omsg.htmlbody='this is a test'
omsg.Send()
lcStr = omsg.getstream
lcStr.SaveToFile(lcFileName,1) 



If you want to get the best response to a question, please check out FAQ184-2483: How to get the best response from the forum first.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close