•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 427,674 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,258 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums
Views: 1236 | Replies: 2
![]() |
•
•
Join Date: Jan 2007
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
Here is VB6 Code:
I am trying to automatically attach a file with outlook email......objMail.Attachments.Add method is unable to read the file "message.doc.pgp" very first time when the code execute.....On second n later executions it start recognizing the file n work fine but y not the first time.
I create the file "message.doc.pgp" by using shell command as follow.
....when this command execute....a file "D:\message.doc.pgp" is created automatically which i later wants to sends as an email attachment....but not recognized during first time code execution as mentioned above.
Thanx a lot
VB Syntax (Toggle Plain Text)
Attachement = objMail.Attachments.Add("D:\message.doc.pgp")
I am trying to automatically attach a file with outlook email......objMail.Attachments.Add method is unable to read the file "message.doc.pgp" very first time when the code execute.....On second n later executions it start recognizing the file n work fine but y not the first time.
I create the file "message.doc.pgp" by using shell command as follow.
VB Syntax (Toggle Plain Text)
Shell "command.com /c pgp -e " & "d:\message.doc " & "Imran Khalid"
Thanx a lot
•
•
Join Date: Sep 2006
Posts: 33
Reputation:
Rep Power: 3
Solved Threads: 1
Since VB's Shell statement starts the outside program and then passes control to the next line of code right away, the outside program probably doesn't have a chance to finish running before you try to attach the file to the email message. You'll get the error because the outside program is still writing the file when your code tries to attach it.
Luckily, the fix for this is really easy. All you have to do is put the following code after your Shell statement, and then tweak the value of the variable "waitSeconds" so that you're waiting long enough for the outside program to finish, but not so long that it looks like your program isn't doing the job:
That should fix the problem! Good luck!
- Sen
Luckily, the fix for this is really easy. All you have to do is put the following code after your Shell statement, and then tweak the value of the variable "waitSeconds" so that you're waiting long enough for the outside program to finish, but not so long that it looks like your program isn't doing the job:
waitSeconds = 5 ' Wait for 5 seconds before trying to use the file
startTime = Timer
Do Until Timer - waitSeconds >= startTime
DoEvents ' Don't want the user to think it's frozen!
Loop- Sen
![]() |
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- read to end of line problem (C)
- One line of code copy char array using pointers (C++)
- php drop down menu to search multiple sql tables (PHP)
- Unresolved External Errors (C)
- Need help with one line of code :( (C++)
- What is wrong with this code? (C++)
- Convert CString to char* (C++)
- fillrect problem (Java)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Coverting a string to a byte array
- Next Thread: ActiveX DLL reference


Linear Mode