Link to home
Start Free TrialLog in
Avatar of chuchazoelrotazo
chuchazoelrotazo

asked on

send an attachment at vb runtime

How can I send a file via email at runtime in visual basic? (it would be wonderful if the user never sees the outlook window)

thanks for any help
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perhaps what easier:

Here is an example using Outlook, customize the code as neccessary:

Private Sub Command1_Click()
  Dim iOutlook As Outlook.Application
  Dim myApp As Outlook.MailItem
  Set iOutlook = New Outlook.Application
  Set myApp = iOutlook.CreateItem(olMailItem)
  temp = "ryancys"
  txtMessage = "Hello World Again!"
  AttachFile = "C:\Documents and Settings\Administrator\My Documents\My Pictures\next.gif"
  myApp.To = "abc@yahoo.com"
  myApp.Subject = "Hello World!"
  myApp.Attachments.Add AttachFile
  myApp.Body = "Hi " & temp & vbCrLf & vbCrLf & txtMessage
  'myApp.HTMLBody = ""
  myApp.Send
  'Do While iOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox).Items.Count <> 0
  '    DoEvents
  'Loop
  MsgBox "Successfully Sent", vbInformation, "Email Sent"
End Sub

Alternatively See use tools:

http://www.freevbcode.com/ShowCode.Asp?ID=109 
Avatar of peterchen092700
peterchen092700

No comment has been added lately.
To cleanup this TA, I will recommend to moderators that this question is:

*** Answered by: Dhaest ***

Please leave any comments here within the next seven days, or finalize the question if you own it
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
peterchen
EE Cleanup Volunteer
Avatar of chuchazoelrotazo

ASKER

thanks to all