Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I email a file from VB? 1

Status
Not open for further replies.

gillianm1

Programmer
Sep 8, 2000
26
0
0
IE
Hi all,
Can someone tell me how to send a text file from within VB?
Thanks,
Gillian [sig][/sig]
 
I have a sendmail dll written in VB that may be of use to you, drop me an email and I'll pass it onto you.
[sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
You can use the Outlook object model to create e mails and send the text file as an attachment.

Simon [sig][/sig]
 
Simon,

If you have some example code for that it would make a great FAQ entry. [sig]<p>Mike<br><a href=mailto:michael.j.lacey@ntlworld.com>michael.j.lacey@ntlworld.com</a><br><a href= Cargill's Corporate Web Site</a><br>Making mistakes, so you don't have to. &lt;grin&gt;[/sig]
 
Thanks guys,
Simon - I've looked at the Outlook object model and have actually figured out out to send a mail(!). I'm having problems though with the Attachment property. What syntax should I be using? The following code gives me an error message when I get to Attachments.....

With oMail

.To = &quot;gmur@bsm.ie&quot;
.Body = &quot;test&quot;
.Subject = &quot;test&quot;
.Attachments = &quot;path&quot;

.Send

End With


Thanks [sig][/sig]
 
The attachments property of the mail item is a collection of attachments, so you have to do:
Set myAttachments = oMail.Attachments
and then use the add method of myAttachments to add a file attachment:
myAttachments.Add(Source, [Type], [Position], [DisplayName])
so your line will be:
myAttachments.Add [sig][/sig]
 
Late Binding example.

Public Sub MailSend()

Dim SendMail, mail1

Set SendMail = CreateObject(&quot;Outlook.Application&quot;)
Set mail1 = SendMail.CreateItem(0)
mail1.Subject = &quot;Files found in directory :&quot;
mail1.Recipients.Add (EmailList)
mail1.Body = &quot;There was a total of &quot; & Count & &quot; files found in the directory &quot; & gDirPath & &quot;.&quot; _
+ vbCr + FilesFound

mail1.Send
MsgBox &quot;Message sent from FTPNotify program&quot;
Set mail1 = Nothing
Set SendMail = Nothing

End Sub [sig][/sig]
 
Mission accomplished!
You people are great - thanks :) [sig][/sig]
 
I have only just looked at my last post and realised that all that I wanted to post didn't actually get posted (I did type more than was actually posted, honest!) - but I guess it doesn't matter now.

Simon [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top