473,890 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

send email without using a macro

86 New Member
Hi. I was wondering if there was a way to send an email without using the Send Object method for a macro. if you use the macro, you will get this warning:

I know in VB .NET you have to import an outlook object or w/e it is and then there were methods that allowed you to edit the To, CC, BCC, subject, etc

I was wondering if there is something similar in VBA to do that.

What i want to do is the following:
1) when user clicks "Send Email" button, it opens up MS Outlook
2) it attaches a report
3) fills out the subject

Aug 1 '11
68 7942
32,584 Recognized Expert Moderator MVP
Jeffrey, did you miss Rabbit's point. The problem is that you have doubled up on the "\" characters. He's correct. That is your problem.
Aug 5 '11 #51
Jeffrey Tan
86 New Member

oh. I'll try that when i get to work today. Maybe that is the problem. Thanks!

Hopefully it is so this can be closed once and for all :P
Aug 5 '11 #52
32,584 Recognized Expert Moderator MVP
There's no question about it Jeffrey. Even if there are any other problems, that is certainly going to cause your issue all by itself. Your code clearly adds an extra "\" in a few places, which will cause file references to fail.
Aug 5 '11 #53
Jeffrey Tan
86 New Member

It just puzzles me because the code I sent to my collegue is the exact one i have and his worked. but i'll be sure to double check every line of code when i go to the office.
Aug 5 '11 #54
32,584 Recognized Expert Moderator MVP
I understand Jeffrey.

We can only work with what's in front of us though. I doubt the code you sent to your colleague is exactly as you posted for us (otherwise it wouldn't work), but that isn't a puzzle we need to worry about just now. If that doesn't resolve itself in the wash then we can look at that too, but we'd need a new question and the code your colleague is actually using (rather than what you think you sent to him at some point - however close a match that may or may not turn out to be).

For now though, I'm confident the code you posted has that problem in it (even if there may be others too).
Aug 5 '11 #55
Jeffrey Tan
86 New Member

yep. what i will do is copy the exact code from my colleague's database, put it into mine and test it.

in terms of programs and all, what are usually the requirements to get AcFormatPDF to work?

Microsoft Access 2007
Adobe Acrobat

do you know of anything else?

trying to open up some possibilities and narrow them down when i troubleshoot this. :)
Aug 5 '11 #56
32,584 Recognized Expert Moderator MVP
yep. what i will do is copy the exact code from my colleague's database, put it into mine and test it.
I hope you're referring to what you will do after we finish here. That is not something for this thread. Nor is the question about how to work with PDFs.

For now, you need to fix the code you posted earlier, exactly as suggested by Rabbit, and report on your success.

Anything further can find its way into a new thread if required.
Aug 5 '11 #57
Jeffrey Tan
86 New Member
understood :)

thanks again for all this help.
Aug 5 '11 #58
8,834 Recognized Expert Expert
@NeoPa & Rabbit:
Ironically, the addition of an extra '\' in the OutputFile Argument of the OutputTo() Method, between the lowest level Folder and start of the Filename, will work. The following Code will work with no problems (notice addition of extra '\'):
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputTable, "tblEmployees", acFormatRTF, "C:\Windows\\Employees.rtf", False
Aug 5 '11 #59
Jeffrey Tan
86 New Member
ok im at work now and i fixed the additional "\" but still the same problem.

here's the code:

Expand|Select|Wrap|Line Numbers
  1. Sub sendEmail()
  3. 'Provides the Send Mail automation. Send an E-Mail and Attachment from Access via Outlook
  4. Dim oLook As Object
  5. Dim oMail As Object
  6. Dim olns As Outlook.NameSpace
  7. Dim strRecipient As String
  8. Dim strBody As String
  9. Dim strSubject As String
  10. Dim strReportName As String
  11. Dim strSource As String
  12. Dim strDestination As String
  13. Dim title As String
  15. Set oLook = CreateObject("Outlook.Application")
  16. Set olns = oLook.GetNamespace("MAPI")
  17. Set oMail = oLook.CreateItem(0)
  19. '************************** Define your own Values here **************************
  21. strRecipient = ""
  22. strBody = ""
  23. strSubject = "Problem Tracking Ticket #: " & [Forms]![User Problem Log]![trouble_no]
  24. strReportName = Mid("Email-Single", 7) & " Problem Tracking Ticket # " & [Forms]![User Problem Log]![trouble_no]
  26. '*********************************************************************************
  28. strSource = CurrentProject.Path & "\"
  29. strDestination = "C:\Windows\Temp\" 'give destination
  30. title = "Single Problem Tracking Ticket # "
  32.     If Not FileExists(strDestination) Then
  33.         MkDir (strDestination)
  34.     End If
  35.     If FileExists(strDestination & title & [Forms]![User Problem Log]![trouble_no] & ".pdf") Then
  36.         Kill strDestination & title & [Forms]![User Problem Log]![trouble_no] & ".pdf"
  37.         DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & strReportName & ".pdf", False
  38.     Else
  39.         DoCmd.OutputTo acOutputReport, "Email-" & Mid(strReportName, 1, 6), acFormatPDF, strDestination & strReportName & ".pdf", False
  40.     End If
  41.     With oMail
  42.       .To = strRecipient
  43.       .Body = strBody
  44.       .Subject = strSubject
  45.       .Attachments.Add strDestination & strReportName & ".pdf", False
  46.       .Display
  47.     End With
  48. End Sub
Aug 5 '11 #60

Sign in to post your reply or Sign up for a free account.

Similar topics

by: dave | last post by:
hi guys I m trying to execute few lines code tht i have copies from microsoft tech script centre. basically its to send email without using any smtp service. u can find the code snippet from following link. http://www.microsoft.com/technet/community/scriptcenter/en tscr/scrent16.mspx while executing this code in vbs file i was getting error:
by: jdph40 | last post by:
I'm using Access 97. In the OnClick event of a button I have the code below. I looks at txtEmail and sends an e-mail message without further action from the user (user does not have to click Send as he would if he used DoCmd.SendObject.) However, I want to attach a report in Snapshot format. How would I modify my code to include a report? Thank you, JD
by: Ronny Sigo | last post by:
Hello all, Can anyone tell me how to prevent my mailprog to display the mail, and just send it ? The code I use is below Any help appreciated .. Thanks Ronny Sigo Private Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
by: Mike | last post by:
In VB6 I could send email via Outlook without using SMTP, Is it possible to do the same in .NET and if so is there any examples of doing this?
by: CLEAR-RCIC | last post by:
I want to send an email from our Intranet site to myself whenever an error happens. Our manager will not let us install SMTP on the web server. Is it possible to send email programatically without SMTP installed?
by: ErwinF | last post by:
Hi there, I would like to know the following: How to send send email attachments using WebDAV in VB .NET? Sample code please................... Thanks for your help.
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and additionally pictures of the product are stored in an images subfolder and the database holds the file name of the relevant picture. The user can then click a button to display the picture in a pop-up window and also another button to email the potential...
by: Boki | last post by:
Hi All, I want to create a program that auto send out email ( not email bomb ) to myself. I tried the MAPI, but it will show a notiifcation message, user need to confirm that. My target is the program can auto send out email for a while ( with a timer, no prob )
by: phill86 | last post by:
Hi I am using the following code to send an email from access via outlook automatically DoCmd.SendObject acSendReport, stDocName, acFormatRTF, "User", , , , , False
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.