Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Attaching Excel Into The Body Of The Email..


I want to send an email(outlook object) from VB code.
In the body of that email, I would like to have an Excel work sheet. NOt as an attachement. but the body itself should have the excel file.

how can I do that programmatically do that?


Sub SendEmail()

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "hello@yahoo.com"
.CC = ""
.BCC = ""
.subject = "This is the Subject line"
.HTMLBody = SheetToHTML(ActiveSheet)
.body = Sheets("DOD Action Plan Email")

.Send

.Display
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End Sub


Help is greatly appreciated.

thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Attaching Body To Email
I have an email program that opens the default email browser inserts the email subject and body. My only problem is that the body needs to be a range of cells is there a way to do this?
Here is the code

---Declarations
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_SHOWNORMAL = 1
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

---function
Sub Choice1_Click()
Dim s As String
Dim hWndX As Long
hWndX = FindWindow("XLMAIN", Application.Caption)

s = "mailto:bobkidkeeper@aol.com"
s = s & "?Subject=test of attachments"
s = s & "&Body=body goes here"
ShellExecute hWndX, "open", s, vbNullString, vbNullString, SW_SHOWNORMAL
End Sub


Know someone that owns a child care business. Go to www.kidkeeper.net. It will help them greatly

Attaching File Link To Body Of An Email
I am using the VB editor within Microsoft Outlook to make an attachment stripper. I am trying to insert hyperlink to the location of where the file was saved to within the body of the email.

Does anyone know how to do this?

I tried to use the following line of code

StrmyFileLocation = "C:Documents and Settings
lellisMy Documents<file name here>
myItem.Body = myItem.Body & "file://" & StrmyFileLocation

The problem is that this creates a hyperlink but only to the point where there is a space. Therefore everything after "Documents" in the string does not get converted into the link.

I found out that whan you manually type file://filename within quotation marks the spaces are recognized.

However it doesn't seem to work when inserting a string in quotes in a VB macro as shown below:

myItem.Body = myItem.Body & Chr(34) & "file://" & StrmyFileLocation & Chr(34)

Everything after the space is not recognized.

Attaching A Html Document To The Body Of An Email
I am using MAPI sessions to create an interface for sending internet faxes using vb6.

Using vb6 I have created an html page. how do I attach the html page to the body of the email after it has been created without physically selecting it?

this html page is my fax cover letter

Attaching HTML File To Email Puts Data In Body
I've spent nearly 3 hours trying to figure this out with a heavy cold and it's driving me nuts!

I have some code to generate (but not send) an Outlook Email.
CODEPublic Sub InitiateOutlookEmail(ByVal strToAddress As String,
                                ByVal strCCAddress As String,
                                ByVal strSubject As String,
                                ByVal strBody As String,
                                ByVal strFileAttachment As String)
   Dim appOutlook       As Object
   Dim objMailItem      As Object
   Dim blnExisting      As Boolean
   Const cPROC          As String = "InitiateOutlookEmail"
   Const olMailItem     As Long = 0
   
   'initialise
   blnExisting = True
   
   'get reference to any currently open Outlook session
   Set appOutlook = GetObject(, "Outlook.Application")
            
   If Not blnExisting Then Set appOutlook = CreateObject("Outlook.Application")
      
   Set objMailItem = appOutlook.CreateItem(olMailItem)
   
   With objMailItem
      'message subject
      .Subject = strSubject
      
      If LenB(Trim$(strBody)) > 0 Then .Body = strBody
      
      .To = strToAddress
      
      'CC Address required?
      If LenB(Trim$(strCCAddress)) > 0 Then .CC = strCCAddress
      
      'check if attachment required and attach
      If LenB(Trim$(strFileAttachment)) > 0 Then .Attachments.Add (Trim$(strFileAttachment))
      
      .Save
      .Display
   End With

   'de-reference objects
   Set objMailItem = Nothing
   Set appOutlook = Nothing

End Sub

Email Excel As Html Body
Hi, I have a excel file with data and an image inside. I would like to email the excel file as the email body via outlook (Not as attachment!) by clicking a button. I found some sample codes in the forum about how to send email but all of them are using attachment method. Can anyone provide some sample code? thanks!

Different Ways To Email Notes Body In Excel
Hi All,

My previous thread got moved although I think this is an Excel issue.

The code, set off with a commandbutton pops up 4 textboxes....
First one for the recipient, second for the subject.

Now, the third and fourth pop up, are textboxes that will complete a range in the workbook. I want to copy - paste this range in the body of the Email.

Isn't this possible with Lotus Notes....? Everything works in the code, just the body isn't there....

Please help!


Code:
Private Sub CommandButton1_Click()
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDoc As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim vaRecipient As Variant 'Array of recipients
Dim vaSubject As Variant 'ze subjekt
Dim vaBodyCMR1 As Variant 'Bodyrange1
Dim vaBodyCMR2 As Variant 'Bodyrange2
Dim i As Long 'Counter

Do
vaRecipient = Application.InputBox( _
Prompt:="Please enter the recipient mailaddress:" & _
vbCrLf & "(Van_Beekum_Dennis@XXX.com)", _
Title:="Recipient", _
Type:=2)
Loop While vaRecipient = ""

If vaRecipient = False Then Exit Sub

Do
vaSubject = Application.InputBox( _
Prompt:="Please enter the subject:" & _
vbCrLf & "(Regarding MSO nmber 00001)", _
Title:="Recipient", _
Type:=2)
Loop While vaSubject = ""

If vaSubject = False Then Exit Sub

Do
vaBodyCMR1 = Application.InputBox( _
Prompt:="Please type the name/title" & _
vbCrLf & "(Sir or Michel)", _
Title:="Recipient", _
Type:=2)
Loop While vaBodyCMR1 = ""

If vaBodyCMR1 = False Then Exit Sub

Do
vaBodyCMR2 = Application.InputBox( _
Prompt:="Please enter the CMR FROM TO Destination:" & _
vbCrLf & "(From Pon Denmark to Finning UK)", _
Title:="Recipient", _
Type:=2)
Loop While vaBodyCMR2 = ""

If vaBodyCMR2 = False Then Exit Sub

Range("aa1") = vaBodyCMR1
Range("aa5") = vaBodyCMR2

'Start a session to notes
Set Session = CreateObject("Notes.NotesSession")


'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", "mailusername.nsf")
If Maildb.IsOpen = False Then
Maildb.OPENMAIL
End If

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = vaRecipient
MailDoc.Subject = vaSubject
MailDoc.Body = Worksheets("Infosheet").Range("aa1:aa14")

'This is supposed to be the property, but works
'on some systems only
'without an apparent reason of failure
MailDoc.SAVEMESSAGEONSEND = SaveIt

'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If

'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
MailDoc.Send 0
MailDoc.Save True, True, False

End Sub

Thanks

Send Excel Worksheets In Body Of Email To Different Recipients
I'm what you could call a very entry-level vb user...I'm trying to set up a macro in excel to send each worksheet within one workbook, in the body of an email, to different email addresses. I found I can do manually going to File, Send to, Mail Recipient..., but can't figure out how to automate...help please?

Add Senders Email In Body Of Email - Emailing With Shellexecute
Hi,
I am loking for a little help. I would like to include the senders email address in an email's body which I generate using shellexecute but after much looking can not find if or where I can get this string from? Any ideas would be much appreciated.

I am using:

VBCODE[
strcommand = "mailto:user@domain.com?subject=Put your subject here&body=message here including senders email address."
Call ShellExecute(0&, vbNullString, strCommand, vbNullString, vbNullString, 5)
]

Attaching SHEETS To Email
First off...I am a relative novice in the VBA world and have used this site as a resource for various projects in the past. Thank you all for your help!

To my question, I am trying to figure out the best way to send various worksheets via email. Basically, I will have a workbook with a "cover sheet" detailing all of the remaining sheets in the workbook (ie, Customer info, part#, description, due date, etc). The remaining sheets will be work orders that are used to produce our parts. What I would like would be to send the "cover sheet" as the body of the email and attach each remaining sheet to the email (to maintain xl formats, etc.).

I know how to attach files using vba, but not individual sheets. Now I'm thinking it isn't possible at all, but whenever I think that you all amaze me with your knowledge & creativity. If you have any input, please let me know.

Thanks!
Tim

Attaching A Image In Email (auto)
I have a issue with creating an olMailItem object in outlook. I can create through VB code and add body, subject and even attachments. I would like to be able to insert a picture(chart) into the email with it visible in the email, not as an attachment.

Basically
If CHTFLAG = True And FullFileName <> "" Then
MyFile = Dir(FullFileName)
If MyFile <> "" Then
.Attachments.Add FullFileName
End If
End If

Instead of the attachment I want the image as if you copied and pasted it into the email.

Any help will be appreciated.

Email In VB??? Adding Message Text And Attaching Files
Does anyone know how to attach a file and set the message text through the ShellExecute command. This is the Code I have so far:


Code:
Success = ShellExecute(0&, vbNullString, _
"mailto:me@myplace.com?subject=Subject Goes Here", _
vbNullString, "C:", SW_SHOWNORMAL)


This command works fine, but I cant figure out what
parameters will set the message text and attachmet files.

Also is there a way to automate this so the user does not
see the default email client, it just sends the message out

Thanks in advance

Send Mail From VB6 Attaching Word Document Into Email
I have a form with a text field that has a path to a word document.

I would like to send this document to some email recipients but not as an attachment but in the body of the email.

I know how to attach a document to the email but to make it display in the body I can't.

Any help would be highly appreciated.

Thanks
Karol


 

Email Body
On my form I have 2 Labels and 4 textboxes, I need to add the contents of the labels (Caption) and the text in the textboxes into my email body when I click a button.

Here's my code so far:

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Private Sub Command1_Click()
ShellExecute Me.hwnd, vbNullString, "mailto:me@here.com;him@there.com?subject=Test&body=body", vbNull, vbNull, SW_SHOWNORMAL

End Sub

What code do I put after &body= or do I have the wrong code all together?

I'm running VB5

Email Body
ShellExecute 0, "Open", "mailto:me@domain.com?subject=Hello"

this will open outlook with e-mail me@domain.com
and subject Hello

how can I also set the body in outlook to a string i choose ?

thanks

RTB And Email (&amp;body)
If I put this in my code:

MailBody = RTB1.Text

and send it to the body of Outlook-Express then there are not CR, how come ??

ShellExecute hwnd, "open", "mailto:MeEmail@Mail.nl" & _
"?subject=" & MailSubject$ & "&Body=" & MailBody _
, vbNullString, vbNullString, SW_SHOW

Output To The Body Of An Email.
Hi All,

I know this has probably been asked here somewhere already, but I can't find it, and maybe you guys can help me out.

I've wrote an estimating program that realy kicks butt. Save me many hours of repeted calculations. You just put in the specs and boom, it kicks out the results to the screen or to the printer. Now I'm trying to get it dump this same info to the "body" of an email. I've got the MAPI to load and open a new email (outlook express), but for the life of me I can't get the output to flow into the body of the email. Can you guys help me out?

Thanks

Pictures In Email Body
I have written a program whereby users can write nice messages in a richtextbox. It also allows for the adding of pictures, and this is where the problem comes in:

After creating their message a user is able to email it. I'm using MAPI to email it, but I don't want the message to become an attachment. It would be great if the entire message, picture and all, becomes part of the emails body (pictures are read from a server, don't worry, I believe in thin client )

I spent all weekend reading up, thinking, fretting, you name it. How do I programmatically insert text and pictures from a richtextbox into an email body, desperation is calling

Using A File For Email Body
I have been asked to put together a little script (I've never really programmed before) in LotusScript. It has to create an email where the body is composed from an existing HTML file. I can create the email fine, using the create object("Outlook.Application") and attach the file no problems.
However I have no idea how to get the body of the file into the body of the email
Any help would be greatly appreciated.

.sendmail And Body Of Email
Is there any way to specify the BODY of the email message via EXCEL API?


Code:
oxlApp.Application.ActiveWorkbook.sendMail(recipient, subject)

Print Email Body Only?
is there a way to do this with a macro, or some plugin perhaps I could make in VB6?
I have seen buttons added to various other applications (word comes to mind) that have special buttons added from some third party app to preform a special function. I would like to have an online form that gets data from textboxes, creates a plain, completed form in email and sends it to joe@wherever.com through our smtp box (which I can do both of these things already)

but on certain end users, I would like to have an option to only print the body (aka the form part) and dont worry about headers and footers and all that. just the stuff in the body.

I know web and vb well enough to code something but i know nothing of integration with other apps. anyone have any ideas?

Body Text In An Email
I am using the following code to paste an Excel worksheet from a workbook into an email (Groupwise NOT Outlook!) as an attachment using the following simple code:


WB.SendMail "xxxx@xxxxx.co.uk", "Email title"
WB.Close


The problem I am having is I can't get the macro to write any body text.

Can anyone help?

RichTextBox To Email Body
I have formatted text in a RTB. (colored, sized and fonts), how can I send it as the body of an email (not as an attachment). I'm sending it to Outlook, I tried .

oOutlook.HTMLBody = txtBody.TextRTF '// this method is in one continous line, unless I include html tags
oOutlook.Body = txtBody.Text '//This is formatted but no color or size

If I use html tags and the user selects an .rtf file to embed in the RTB that would be a hell of lot of parsing.

Formatting Body Of An Email
Can someone help me with formatting the body of an email message? I'm doing okay except that I need everything to appear on separate lines. The only thing in the body of the message is all the contents of a list box. Here's what I've got...

For i = 0 To List1.ListCount - 1
List1.ListIndex = i
strBody = strBody & vbCrLf & List1.Text & vbCrLf
Next i

strMailTo = "mailto:&subject=Subject&body=" & strBody
lngResult = ShellExecute(Me.hwnd, "Open", strMailTo, "", "", vbNormalFocus)


The problem is that it is going into the body of the email like this:

Line 1 Line 2 Line 3

when I need it to go like this

Line 1
Line 2
Line 3

Any help appreciated. Thanks in advance.

Shellexecute Email And Body
i know that this will open outlook and put the email address in and put hello in the message box.
how do you get the text from a textbox in the body.


Code:
ShellExecute Me.hwnd, vbNullString, "mailto:someones email@somewhere?body=Hello", vbNullString, "C:", SW_SHOWNORMAL

thank you
casey.

RichText Vb In Body Email
I would want to insert in body of an email sended via smtp the content of one richText Box of visual basic with richtext1.textRTF. it is possible to make this?

There is mime for rich text?

Email Body Length
Can someone help me out abit ....I'm using the code below for email,But after the body reaches about 500 space,letters,and or numbers it will not send.......can someone tell me what part of the code for the body do I change to add more room.....I'd like to double or triple it......

Public Function SendMail(lhWnd As Long, Optional Address As String, _
Optional Subject As String, Optional Body As String, _
Optional CC As String, Optional bcc As String, Optional Attachement As String)


Dim strCommand As String

'bygger opp "mail-strengen"
If Len(Subject) Then strCommand = "&Subject=" & Subject
If Len(Body) Then
Body = Replace(Body, "&", "%26")
Body = Replace(Body, " ", "%20")
Body = Replace(Body, vbCrLf, "%0D%0A")
Body = Replace(Body, vbCr, "%0D")
Body = Replace(Body, vbLf, "%0A")
strCommand = strCommand & "&Body=" & Body & "%0D%0A"
End If

If Len(CC) Then strCommand = strCommand & "&CC=" & CC
If Len(bcc) Then strCommand = strCommand & "&BCC=" & bcc
If Len(Attachement) Then strCommand = strCommand & "&Attacth=" & Chr(34) & Attachement & Chr(34)

'passer på at første tegn er et ?-tegn
If Len(strCommand) Then
Mid(strCommand, 1, 1) = "?"
End If

'legger til teksten "mailto:" og hoved adresse
strCommand = "mailto:" & Address & strCommand

'Starter default mail program v.h.a shellexecute
Call ShellExecute(lhWnd, "open", strCommand, _
vbNullString, vbNullString, SW_SHOWNORMAL)

End Function

Email Body Text - Help!
Ok, firstly thanks to everyone who looks at this thread and posts, as I'm finding solving my current problem not only tricky, but extremely irritating.

Basically, I am tweaking the website for the company where I work and am trying to grab information from a form which potential customers fill out, then email those fields to our email address.

The form has been written, and works fine. I've also written the script to grab the info and email it, which runs fine...

...my problem lies with tweaking the body text to include headers which will help those who receive the emails ascertain to which field the information that has been mailed is taken (currently the form information is simply listed in the email, with a line break between each section. So, for example, the first line shows whatever the customer filled out in the 'Name' field on the form, but nothing to indicate to the email reader that that is the name field).

Incidentally, please disregard the strange field names. They are all correct, and do work, they are just thus named due to me being lazy and simply copy/pasting new fields in, rather than naming each one.



My script, which grabs from the form, is as follows. This script works perfectly, I just don't know how to add indications into the body text as to which bit of information belongs to which field.

<% @LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>


<p>
<%

Set Mail = Server.CreateObject("SMTPsvg.Mailer") 'create an Asp mail component.
Mail.FromName = Request.Form ("email")
Mail.FromAddress = Request.Form ("email3")
Mail.RemoteHost = "mrvnet.kundenserver.de" ' The mail server you have to use with Asp Mail
Mail.AddRecipient "US", "OUREMAIL@OURDOMAIN.com"
Mail.Subject = "Customer Request"
Mail.BodyText = Request.Form("email") & vbcrlf & Request.Form("email2") & vbcrlf & Request.Form("email4") & vbcrlf & Request.Form("email5") & vbcrlf & Request.Form("email6") & vbcrlf & Request.Form("email7") & vbcrlf & Request.Form("email72") & vbcrlf & Request.Form("email73") & vbcrlf & Request.Form("email732") & vbcrlf & Request.Form("email7322") & vbcrlf & Request.Form("email733") & vbcrlf & Request.Form("info")
if Mail.SendMail then
Response.Redirect("thankyou.asp")
else
Response.Write "Mail send failure. Error was " & Mail.Response
end if
Set Mail = Nothing


%>
</p>
<p>&nbsp;</p>
</body>

</html>

How Do I Send A URL In The Body Of An Email?
Hi, I am super new to this and I cannot find info on this in my searchs. Here is what I want to do..

I am creating an Outlook mail message object. I can set the recipient, subject, and body as text, but what I want to do is to send a hyperlink/url in the body of the messge.

Any Ideas?

Here is my code:

    Dim Body As String
    Dim myOlApp As Object
    Set myOlApp = CreateObject("Outlook.Application")

    Body = "This is a neat URL: Http://www.google.com"
    
    Set emailMsg = myOlApp.CreateItem(0)
    
    emailMsg.Subject = "Neat URL"
    emailMsg.Body = Body
    emailMsg.Recipients.Add "me@nowhere.com"
            
    emailMsg.Send

Maybe I should declare it differently? I do not know.... Any hlpe is greatly appreciated!

Thanks!

Sending HTML In EMail Body
I am trying to send html formatted text in my app and I am using the winsock control. I got this code below working fine, but i cannot get it to display the html only plain text. Can anyone help?




With ctlSMTP1
' set mail server
.MailHost = "my.domain.com"
.MailPort = 25

' set message properties
.Subject = "Test mail from SMTP control"
.ToPerson = "My name"
.FromAddress = "me@here.com" ' not a real address
.FromPerson = "Name <me@here.com>"

' add addresses
.AddAddress "you@email.com"

' set body
.BodyData = "<font color=green>Welcome to my email</font>" & _
vbCrLf & vbCrLf & "<h1>It is working...</h1>"

' send
.SendMail
End With

Send Email: Contactitem.body HELP!
Outlook 2000, VB 6.

Want to add functionality:

Contact and/or Journal item, send [Notes] field as email to hardcoded address(s) by

1. select text, then with control button, send

and / or

2. Using control button, send all [Notes]

How to do it?

Thank you.

Send Email, As Body, With Chart?
Edit by Moderator:
Re: http://www.xtremevbtalk.com/showthread.php?t=236989

There wouldn't happen to be any new ideas or developments on this problem, would there? I'm hoping to do the same as above.

Edit:
Original thread is over 1 month old and therefore archive-only. Please create your own thread in future.

Thank you.

Email With Doc Directly In Body, Not As An Attachment
Hi everyone,
Just need to automate (working in Access) an email where the body will be something from word / excel, NOT as an attachment but directly in the body.

I tried already with DoCmd.SendObject, but the body is just a string to be written in the code:
DoCmd.SendObject , , , test@com, , , "Subject", "body is a string", False

I tried also with .body, but same problem.

Using SendKeys to paste what I copied before does not work apparently.

Any ideas are more than welcome. Thanks

Need Help Body Back Ground In Email
Hi Friends

I have a program which sends mails to the customers... I want to put a body background..

But I could view the body back ground others could not.. can any one help.. the code is follows..

Also if i give instead of body background as <img src> only i could view.

==========
Dim objOutlook As Object
Dim objOutlookMsg As Object
dim body1 as string

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(0)
With objOutlookMsg
.To = "someone@hotmail.com"
.Subject = "Hello..."

body1 = "<html><p><b><font size=5> Dear Customer </font><b></p><p>&nbsp;</p><center><table width= 285><tr><font color=#cbfea5 size=4 align= center> </font><br><br><font color= #f80000 size=5> Have a Nice Day </font></tr></table></center><body background=cust.jpg></body></html>"
.HTMLBody = body1
'.Attachments.Add ("c:emailcuso.jpg")
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing

Email With Mapi: Body Message
I had writen a function to send an email from Vb using MAPI functions. The code is shown below:

MAPISession1.SignOn
With MAPIMessages1
.SessionID = MAPISession1.SessionID
.MsgIndex = -1
.Compose
.RecipDisplayName = ccC
.MsgSubject = cS
.MsgNoteText = ""
.AttachmentName = Right(cDestino, 16)
.AttachmentPathName = cDestino
.Send
End With
MAPISession1.SignOff

My default email app is Incredimail.
It works fine, but always I get the same unexpected information in the body message:
--------------Boundary-00=_2Z56N0X1VA4000000000
Content-Type: Text/Plain
Content-Transfer-Encoding:


--------------Boundary-00=_2Z56N0X1VA4000000000--

What's wrong? How I can supress that message?

Thanks.

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.

Autofilling Out Body Of An Email In Outlook
Hello peeps....

My prog creates default emails at the moment with senders email and Subject lines ready populated. Is it possible (or easy) to automatically fill the body aswell and send it automatically?

Thank you oh Gods of enlightenment and beer breath.

Problem Getting Link In Body Of Email
In my asp page I am sending a an email and need to have a link in the body. The problem is that it is not showing up as a link in the email. I have tried using chr(34) as well but that doesn't work either. Any suggestions?

VB Code:
mymail.Body="At your request, the following new password has been created for the TrafficBoss Client Center:  <B>" & pass &"</B> . <BR><BR>Please use the following link to login and change your temporary password: <a href ""https://www.trafficboss.com/clientinterface/login.asp"">TrafficBoss Client Center</a>"

Can Email Body Be Formatted Using A Macro?
Hey All,

Do not do any VBA programming but have been asked to write a macro to allow users to auto-format their email body. I wrote this so far but had some questions I'm hoping you can answer. Is it best to do it the way I have and assign the formatted text to a string or should I be using the PRINT # method? Also, I wanted to test below and in Excel, using a macro you can assign the code execution to a keyboard key like 'G8' that automatically runs your code. I can not find this same functionality and think I am missing something. Writing a macro for Outlook is not the same as writing one for Excel? :

Private Sub NonConformanceTemplate()
    Dim myMail As Outlook.MailItem
    Dim strBodyFormat As String
    
    Set myMail = Application.CreateItem(olMailItem)
    myMail.Subject = "Non-Conformances"
    strBodyFormat = Chr(13) & _
                    Chr(13) & _
                    Chr(13) & _
                    "SOP 1.2/F7" & Chr(13) & _
                    " NON-CONFORMANCES " & Chr(13) & _
                    Chr(13) & _
                    "1.DESCRIPTION OF SITUATION/PROBLEM " & Chr(13) & _
                    "(include date of incident or date situation noticed):" & Chr(13) & _
                    Chr(13) & _
                    Chr(13) & _
                    Chr(13) & _
                    "2.NOTIFIED SUPERVISOR: Y N " & _
                    " NAME:_______________________" & _
                    " DATE:_______________________" & _
                    Chr(13) & _
                    Chr(13) & _
                    "3.CORRECTIVE ACTION TAKEN: " & _
                    Chr(13) & _
                    Chr(13) & _
                    Chr(13) & _
                    Chr(13) & _
                    Chr(13) & _
                    "Testing" & Chr(13) & _
                    "Continue under current conditions: "
                 
    myMail.Body = strBodyFormat
    
End Sub

Help Sending Email With Rtf Contents As Body In Vb
Hi,

I am trying to send a document using vb.net and outlook and words, The type of file i would like to send are (rtf, doc, txt) as the message body in the outlook message. Any one with experince in this area the help will be surely appreciated.

I have added the code below i get some type of hresult type error when i run this.





Public Sub SendDocMsg(ByVal subjectp As String, ByVal pEmail As String, _
    ByVal fileDirLocation As String)

        recipient = pEmail
        subject = subjectp

        Dim oLApp As Object
        Dim oItem As Object
        Dim oDoc As Object
         

        On Error GoTo errorHandler

        
        'Create a new mailitem
        ' oOutlook = New Outlook.Application
        oLApp = CreateObject("Outlook.Application")
        oItem = oLApp.CreateItem(0)
        oDoc = CreateObject("Word.Application")
        oDoc.Visible = True
        oDoc.Documents.Open(fileDirLocation)


        With oItem

            'Set the recipient for the new email
            .To = mRecipient

            'Set the recipient for a copy
            '.CC = "recipient2@mail.com"

            'Set the subject
            .Subject = mSubject

            'The content of the document is used as the body for the email
            .Body = oDoc.ActiveDocument.Content

            .Send()
        End With

        
errorHandler:
        MsgBox(Err.Number & " " & Err.Description)
        'Clean up
        oItem = Nothing
        oLApp = Nothing
        oDoc = Nothing

    End Sub ' SendMsg

Does Anybody Know How To Send An Email Which Includes Message Body?
Hi.

I have an Excel file which I want to incorporate macros and VB to automatically format a report, and then email out. It's all working well apart from the fact that I can't seem to be able to include a message body in the email. At the moment, I have a 'Send' button, which uses the following code to save one particular sheet of the workbook (the sheet that contains the report) as a seperate Excel file and then email it.

Public Sub SendIBM()
Dim strDate As String
Sheets("IBM Options").Copy
strDate = Format(Date, "dd-mm-yy")
ActiveWorkbook.SaveAs "IBM Options Backlog " & strDate & ".xls"
ActiveWorkbook.SendMail Sheet1.txtEmailTo.Text, "IBM Options Backlog " & strDate
End Sub

On searching google I found this post

http://www.xtremevbtalk.com/showthread.php?t=90043

which seems to solve the problem for another user - but could anybody help me modify this code to work with my file? Please bear in mind that my VBA skills are pretty basic, and have only got the program working as well as it does with a lot of others people help, so if anybody can assist please can you talk in plain English with clear instructions for me?

Many thanks in advance,

Andy.

How Can I Find Out If The Email Body Is In Html Format?
i'm using msoutlook to manipulate the emails.
I want to know the way to find out that the body of the email message is written by html..
I see that outlook can tell whether the body of the message is html or plain text,. but how can i tell it programmatically?

thank you

OUTLOOK 2K/VBA Problems To Access The Email Body
Hi Dev fellows,
I am trying to grab the body of an bounced email, flagged whit a System administrator subject, using VBA.

The body of this email look like this:
....there is the email address too
_____________
Your message did not reach some or all of the intended recipients.
Subject:Web Survey (6/11/2003)
Sent: 6/11/2003 12:00 AM

The following recipient(s) could not be reached:
'cyndi_k@o.com' on 6/11/2003 12:09 AM
Unable to deliver the message due to a communications failure
The MTS-ID of the original message is: c=us;a= ;p=interim healthca;l=IHCMSX010306110408M2W1LN0R
MSEXCH:IMS:Interim HealthCare:IHC:IHCMSX01 3902 (000B09B6) Host Unknown
______________
Example at http://www.venemlb.com/test.msg

By the way OUTLOOK RULES DOES NOT CATCH THE BODY NEITHER.....

However after use:
objMail.SaveAs MyPath & MyFileName, olTXT

A new text file is created with the from, To, and Subject fields, not the body...
However for any other message I get the to, from, subject and body field.

Question: Is any reason why the body field is not been grabbed? However, if I do it manually trough File|SaveAs|as .txt file, the body part gets saved in the TXT file....

Thanks for your help pals!

Help Sending A Worksheet Content In Email Body
Hi All,

Basically I have a workbook which keeps track of how often a list of documents are reviewed. If a document's "Last reviewed date" falls beyond 180 days, conditional formatting turns the cell red to warn the owner.

What I now want to be able to do is to automatically email the owner of those documents to tell them to take action. I've written the below but this will email the entire workbook to the user rather than just the contents (or a range thereof) of a worksheet.

Can this be achieved? If so how?

Many Thanks in advance

Cliff



VB Code:
Private Sub MailDocument()'This routene mails the customerDim stDocName, User As StringDim MyMessage As ObjectUser = "cliff@clifforddashwrightdotcodotuk"ColUpdateoverdue = 9For a = 2 To Sheets.Count        Sheets(a).Activate        For x = 3 To ActiveSheet.UsedRange.Rows.Count            If Sheets(a).Cells(x, ColUpdateoverdue) = "Yes" Then            With ThisWorkbook               '.HasRoutingSlip = False                With .RoutingSlip                    .Delivery = xlAllAtOnce                    .Recipients = User                    .Subject = "These OSM Documents are due for review"                    .Message = Sheets(a).Cells(x, 8) & " Document " & Sheets(a).Cells(x, 1) & " is due for review"                    .ReturnWhenDone = False                                    End With            .Route            End With                     'just for testing only                 MsgBox Sheets(a).Cells(x, 8) & " Document " & Sheets(a).Cells(x, 1) & " is due for review"            Else            End If        Next xNext a      End Sub

Syntax To Fill Body Of Email Message Through Vb6
HI, in my send routine for a email messaze sent through vb6 Im trying to write a line of code that says an advsier on your team has booked time off the details are as follows:" name = text2, date from = text3 and date until = text4,

I want the code to pick up the detaisl from text boxes on a form and send them as the body of the email.. the syntax im currently using is as follows..

Code:
.body = "An adviser on yout team has tried to book time off, the details are below:" and "Name" = text2.text and "Date from" = text3.text and "Date Until" = text4.text


It doesnt work so i wondered if anyone can advise on how this line of code needs to be written?
sean

Send Email From VB With The Image In Body And Not As Attachment
Hai,

In outlook, you can directly insert a picture in the body of the message. Is there a way by which we can insert pictures to the body of the message using VB code. could anyone help me out as soon as possible. I dont want the image to be sent as an attachment

Thanks & Regards,
K. Sripriya

OUTLOOK 2K/VBA Problems To Access The Email Body
Hi Dev fellows,
I am trying to grab the body of an bounced email, flagged whit a System administrator subject, using VBA.

The body of this email look like this:
....there is the email address too
_____________
Your message did not reach some or all of the intended recipients.
Subject:Web Survey (6/11/2003)
Sent:6/11/2003 12:00 AM

The following recipient(s) could not be reached:
'cyndi_k@o.com' on 6/11/2003 12:09 AM
Unable to deliver the message due to a communications failure
The MTS-ID of the original message is: c=us;a= ;p=interim healthca;l=IHCMSX010306110408M2W1LN0R
MSEXCH:IMS:Interim HealthCare:IHC:IHCMSX01 3902 (000B09B6) Host Unknown
______________

By the way OUTLOOK RULES DOES NOT CATCH THE BODY NEITHER.....

However after use:
objMail.SaveAs MyPath & MyFileName, olTXT

A new text file is created with the from, To, and Subject fields, not the body...
However for any other message I get the to, from, subject and body field.

Question: Is any reason why the body field is not been grabbed? However, if I do it manually trough File|SaveAs|as .txt file, the body part gets saved in the TXT file....

FOR MORE INFO PLEASE CHECK AN EXAMPLE AT:
URL

Thanks for your help pals!

Enclosing A Html File In The Email Body
Hi there,

I have a report in html format that need to be sent out as the body (not attachement) of the email using outlook.


In order to accomplish that I think I will have to read the html report into a string var then assign the string to htmlBody.

I am wondering if there is any simpler way to do it something like:

                                 htmlBody = myReport.html     (of course this won't work)


Thanks in advanced!


Tabbey
    

Save Email Body To A Text File
Hi,

I am hoping some guru can help me with a problem I have...

I am running an access database, what I need to do is loop through all the mails in a public folder skipping any mail with attachments, then save the mail body to a text file and then stored to a location on the harddrive.

Any help would be great. Thanks.

Pasting Selection Of Cells Into Body Of Email
I know how to send spreadsheets as attachments and how to send strings in the body of emails. I have all of this working. I now need to be able to paste/import a selection of cells in an excel file into the body of an email. I have tried mail.object = range("a1:b5"), as an example, but it doesn't work. Any ideas?

Copyright © 2005-08 www.BigResource.com, All rights reserved