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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moved VBA: Email through excel w/ attachment help needed please!!

Status
Not open for further replies.

Josh1

Technical User
Sep 14, 2003
6
US


I used this code to send email through excel and got back an error message “User defined type not defined”. Any help would be much appreciated. Also if you know an easy way to send the last file saved as an attachment that would also be a big help



Thanks

Josh Jacob



Sub Send_Outlook_E_Mail()

Dim oOutlook As New Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim OMailitem As Outlook.Mailitem
Set oNameSpace = oOutlook.GetNamespace("MAPI")
oNameSpace.Logon '

Set OMailitem = oOutlook.CreateItem(olMailItem)
With OMailitem
.Subject = "Subject Text"
.Recipients.Add "mailaddress"

.Body = "Your body text here"
.Body = "more text here"
.Body = "more text here"
.send

End With

oNameSpace.Logoff
Set oNameSpace = Nothing

End Sub

Sub SendActiveBook()
ActiveWorkbook.HasRoutingSlip = False
With ActiveWorkbook.RoutingSlip
.Recipients = "somebody@domain.com"
.Subject = "Distribution: test.xls"
.Message = "Hello"
.Delivery = xlAllAtOnce
End With
ActiveWorkbook.Route

End Sub
 
Hi,

It seems that you don’t have a reference to the outlook library. In VBE go to:

Tools > References… and add a checkmark to “Microsoft Outlook 10.0 Objects library.



Jean-Paul
Montreal
jp@solutionsvba.com
mtljp2@sympatico.ca
 
Hi Jean-Paul

Any ideas on how to you late binding for reference instead?
 
Hi,

You will find your answer in the thread
thread707-647522 posted last time on Sept 09,in this section.


Jean-Paul
Montreal
jp@solutionsvba.com
mtljp2@sympatico.ca
 
Hi Jean-Paul

Thanks for the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top