473,473 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Create 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

Thanks!
Aug 1 '11
68 7829
NeoPa
32,556 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
@NeoPa:

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
NeoPa
32,556 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
@NeoPa:

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
NeoPa
32,556 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
@NeoPa:

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
NeoPa
32,556 Recognized Expert Moderator MVP
Jeffrey:
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
ADezii
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()
  2.  
  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
  14.  
  15. Set oLook = CreateObject("Outlook.Application")
  16. Set olns = oLook.GetNamespace("MAPI")
  17. Set oMail = oLook.CreateItem(0)
  18.  
  19. '************************** Define your own Values here **************************
  20.  
  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]
  25.  
  26. '*********************************************************************************
  27.  
  28. strSource = CurrentProject.Path & "\"
  29. strDestination = "C:\Windows\Temp\" 'give destination
  30. title = "Single Problem Tracking Ticket # "
  31.  
  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
NeoPa
32,556 Recognized Expert Moderator MVP
@ADezii
Thanks for the clarification. I should apologise for misleading. I always use Replace() myself to ensure such an anomaly never arises.

@Jeffrey
I'm sure the problem is still the same. Would you mind posting the details again as I don't keep details of all the threads I work on in my RAM, and aging as I am, my HDD is not too hot either. Short of that I would need to search through the thread again, and it's a long thread already.
Aug 5 '11 #61
Jeffrey Tan
86 New Member
ah i noticed something else...

see the attached screenshot..



there's no PDF format.

i looked at my colleague's computer and there is PDF... now i'm 100% sure that is the problem.
Aug 5 '11 #62
NeoPa
32,556 Recognized Expert Moderator MVP
Did you not say you were developing on a 2007 system? If not, then acOutputPDF was introduced in 2007 so that would explain the omission. If so, then I can only guess that support for PDF is an optional inclusion and you may need to reinstall the software making sure that PDF support is included.
Aug 6 '11 #63
Jeffrey Tan
86 New Member
@NeoPa:

Yeah the database was recently converted from 2000 (or 2002, i forget) to 2007. doubt it has anything to do with the fact that he's using windows 7 and i'm still on XP. maybe ill try to reinstall access 2007 and adobe pdf.
Aug 6 '11 #64
Jeffrey Tan
86 New Member
omg finally i fixed it!

i reinstalled MS office and adobe acrobat... still the same problem.. so i figured i'd google it and see if anything came up.

Turns out that I was missing an addin for 2007.

http://support.microsoft.com/kb/934833

so i downloaded the Microsoft Save as PDF or XPS addin, installed it and now it works perfectly :)
Aug 8 '11 #65
NeoPa
32,556 Recognized Expert Moderator MVP
So not only is 2007 required, but a separate download is also required. Sorry for the bum info Jeffrey. I had no idea that PDF wasn't available as standard in 2007 (I still only use up to 2003 personally). Well done for clearing that up though
Aug 8 '11 #66
Jeffrey Tan
86 New Member
@NeoPa: yeah i didn't know either lol.

So I guess this would be a good reference for those who want to try the same and gets to this problem as well :)
Aug 8 '11 #67
NeoPa
32,556 Recognized Expert Moderator MVP
I guess so. It can't hurt :-)
Aug 8 '11 #68
anoble1
245 New Member
In my database I do something very similar. Works GREAT!
Something like this:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "rptCrewAuthorization", acFormatSNP, outFileName(0), False
Expand|Select|Wrap|Line Numbers
  1. GenerateEmail "asdf@asdf.com", "sdfg@sdfg.com;dfgh@dfgh.com", "fghj@fghj.com;ghjk@ghjk.com", ContractorName.Value & " Crew Authorization " & cmbContractID.Column(1, cmbContractID.ListIndex) & "-" & AuthNum.Value & " - Starting " & Forms!frmCrewAuthorization!AuthDate.Value, Forms!frmCrewAuthorization!Name.Value & "'s Crew" & vbCrLf & vbCrLf, outFileName, False
Aug 10 '11 #69

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

Similar topics

1
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...
3
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...
1
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...
6
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?
4
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...
6
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.
3
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...
2
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...
3
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
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...
0
agi2029
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,...
1
isladogs
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...
0
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...
0
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...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.