Hello,
A simple request I am sure, but I am unclear of the procedure. I have limited experience with VB, so here goes:
I am trying to create a simple VB application that will bring up a form box with a TextInput for an email address and a SEND (caption) button only.
The function of this application will, when the SEND button is clicked Outlook 2010 will:
1. Open and populate the To: field with the email address from the Text Box input.
2. Attach a file rom a specified folder (same with all outgoing emails)
3. Close Outlook
Basically our secretary should have this Form Input box on her desktop, type an email address and hit SEND.
Any detailed assistance is appreciated.
In Outlook press ALT+F10
Create a new 'UserForm', and add a Textbox, and a Button on it.
Give the butten a correct name, and doubleclick it.
enter next code: -
Private Sub Send_Click()
-
Dim msg As Outlook.MailItem
-
Set msg = Application.CreateItem(olMailItem)
-
msg.Subject = "Hello World!"
-
msg.To = Me.TextBox1.Value
-
msg.Attachments.Add "c:\temp\test.pdf", olByValue, 2, "test"
-
UserForm1.Hide
-
msg.Send
-
Set msg = Nothing
-
End Sub
-
-
after that, rightclick on 'Modules', and create a module with next code: -
Sub mailthis()
-
UserForm1.Show
-
End Sub
-
save everything,
a shotcurt with the following command should start tha macro (providing the names are equal): - "C:\Program Files\Microsoft Office 15\root\office15\outlook.exe" /autorun "Project1.mailthis"
5 4266 Luuk 1,047
Expert 1GB
What about the 'Right Click'/'Send to'/'Mail recipient'?
If your secretary is not smart enough to do that, your secretary should get a basic computer course.
This will benefit you, and your company.
An option, yes...but there is a reason for the method I have inquired about!
Luuk 1,047
Expert 1GB
In Outlook press ALT+F10
Create a new 'UserForm', and add a Textbox, and a Button on it.
Give the butten a correct name, and doubleclick it.
enter next code: -
Private Sub Send_Click()
-
Dim msg As Outlook.MailItem
-
Set msg = Application.CreateItem(olMailItem)
-
msg.Subject = "Hello World!"
-
msg.To = Me.TextBox1.Value
-
msg.Attachments.Add "c:\temp\test.pdf", olByValue, 2, "test"
-
UserForm1.Hide
-
msg.Send
-
Set msg = Nothing
-
End Sub
-
-
after that, rightclick on 'Modules', and create a module with next code: -
Sub mailthis()
-
UserForm1.Show
-
End Sub
-
save everything,
a shotcurt with the following command should start tha macro (providing the names are equal): - "C:\Program Files\Microsoft Office 15\root\office15\outlook.exe" /autorun "Project1.mailthis"
Perfect, thank you Luuk, that does work! Keeping the form open is perfect, however the line for closing Outlook upon sending is what I also need.
I played with the following, but unable to mesh:
objMail.Send
objOutlook.Quit
Set objMail = Nothing
Set objOutlook = Nothing
Luuk 1,047
Expert 1GB
will close Outlook,
but only if the mail is already send,
otherwise some notification is show about Outlook being busy sending a mail.....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: joe215 |
last post by:
I want my users to send emails from a Windows app that I am developing in
Visual Basic.NET 2003. I found a good example of sending email to a SMTP
server using the SmtpMail class. However, using...
|
by: Bonj |
last post by:
Right guys.
(I would like a solution to this in VB6 as this is what our needy app is
written in, but any solutions that involve .NET would be much appreciated
likewise as I could instantiate...
|
by: Frank |
last post by:
I think I've confused myself completely here :-)
I have used System.Web.Mail, but am not sure if this works with Exchange Server 5.5. I asked the client if they're email server supported SMTP, and...
|
by: =?Utf-8?B?QXJuZSBCZXJ1bGRzZW4=?= |
last post by:
In my vb.net 2005 app ...I'm sending email via Outlook 2003. How do I
eliminate that annoying outlook box when sending the email.
Thanks
|
by: Paridevi |
last post by:
Hai ,
i want to send email in .Net Using OutLook Express,My Project is Web Application using vb.Net 2003 with SQL Server 2000.I have searched a lot in Google, but ican't get any...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| | |