|
-
Apr 28th, 2003, 09:03 AM
#1
Thread Starter
Lively Member
Sending Email with vb - attachments become body?
I am using vb to send out emails automatically with outlook 97 and exchange server 5.5. Internally everything works great, but when emails go externally the attachment (text file) becomes part of the body of the text. I believe this code was working at one time, but stopped working a few weeks ago. Does anyone know of any patches for outlook or exchange that would cause this or if i can change my code to fix the problem? The email and my source are shown below - If anyone can help me, it would greatly be appreciated.
code:
Sub SendEmail(attachfile, txtEmailList, txtReportName)
Dim o
Dim m
Set o = CreateObject("Outlook.Application")
Set m = o.CreateItem(0)
m.To = txtEmailList
m.Subject = txtReportName
m.Body = " "
m.Attachments.Add attachfile
'Repeat this line if there are more Attachments
m.Send
'm.Send 'If you want to just send it
End Sub
Email example:
Date: Thu, 24 Apr 2003 08:15:21 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Content-Type: multipart/mixed;
boundary="----_=_NextPart_000_01C30A5B.2D400D60"
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_000_01C30A5B.2D400D60
Content-Type: text/plain
------_=_NextPart_000_01C30A5B.2D400D60
Content-Type: text/plain;
name="report2.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="report2.txt"
Application~SSN~Emp Name~Term Beg~Term End~Amount~Check~Receipt =
Proof~Grades Proof~Pay to Name =
=
=
=
=
=
=
=
=
=
=
=
=
1200~xxx~NICHOLE, WHITFIELD =
L~01/06/2003~05/05/2003~1326~32843~01/07/2003~~Grand Valley State =
University
1282~xxx~RACHEL, REEDER R~03/13/2003~04/17/2003~1257~35089~~~*** =
Invalid Award Vendor 100571
------_=_NextPart_000_01C30A5B.2D400D60--
**********************
** LEGAL DISCLAIMER **
**********************
This E-mail message and any attachments may contain
legally privileged, confidential or proprietary
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of
this message to the intended recipient(s), you are
hereby notified that any dissemination, distribution
or copying of this E-mail message is strictly
prohibited. If you have received this message in
error, please immediately notify the sender and
delete this E-mail message from your computer.
-
Apr 28th, 2003, 09:16 AM
#2
Fanatic Member
I had a similar problem, different email method. The method I used had "position" parameters for the attachment.
VB Code:
With email
.position(0) ' put the file in the body
.position(1) ' made the file just an attachment
You may want to see if there is a similar parameter in the method you're using.
-
Apr 28th, 2003, 10:32 AM
#3
Thread Starter
Lively Member
I wasnt able to find a position property anywhere or anything similar? Does anyone else have any ideas or possible solutions - as u can see my email routine is very simple - i do not need to use outlook - i can use any methos that is simple - I just need to send out an email with a text attachment - any help would be appreciated!
-
Apr 28th, 2003, 10:45 AM
#4
To create an email and add attachment(s)...
Code:
Option Explicit
Private Sub cmdSend_Click()
Dim oOutlook As Outlook.Application
Dim olEMail As Outlook.MailItem
Dim olAttach As Outlook.Attachments
Dim sAttach As String
Set oOutlook = New Outlook.Application
Set olEMail = oOutlook.CreateItem(olMailItem)
olEMail.To = "RobDog888@???.com"
sAttach = App.Path & "\" & "Test.txt"
Set olAttach = olEMail.Attachments
olAttach.Add sAttach, 1, 1, "Test.txt"
olEMail.Body = "RobDog888's email attachment example."
olEMail.Send
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|