I do not know if this is posible using VBA, but I have a document in word that I would like to send to the same recipients every month, how can I send it. I would be sending it utilizing outlook. Thanks
Actually I figured out how to send the emails. Another issue that I have come across is the security settings. Everytime you send an email from a word document through outlook you get a message "A program is trying to automatically send e-mail on your behalf. Do you want to allow this?" I understand that this is probably a security setting to prevent macros from being sent but is there a way for me to invoke some sort of signature to say yes this is OK from this user. Thanks.
My code now is:
Public Sub SendDocument()
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "mike_718@someplace.com"
.Subject = "New subject"
'Add the document as an attachment, you can use the .displayname property
'to set the description that's used in the message
.Body = ActiveDocument.Content
.Attachments.Add Source:=ActiveDocument.FullName, Type:=olByValue, _
DisplayName:="Document as attachment"
.Send
End With
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.